Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate random id #19

Closed
jennybc opened this issue Oct 31, 2016 · 6 comments
Closed

Don't generate random id #19

jennybc opened this issue Oct 31, 2016 · 6 comments

Comments

@jennybc
Copy link
Contributor

jennybc commented Oct 31, 2016

I'm not sure if this is a listviewer problem or an htmlwidget problem.

I'm using listviewer in an R markdown website and every time I build the site, the listviewer widgets have a diff, even thought the data does not change. I made a commit consisting solely of this phenomenon as an example:

jennybc/purrr-tutorial@010cb57

Is there any way to suppress that?

@timelyportfolio
Copy link
Owner

This is not unique to listviewer, but there is an easy solution for all htmlwidgets that I failed to provide for listviewer. All htmlwidgets will get a pseudo-random id unless they specify the elementId in createWidget. I just added to jsonedit, and I will try to get up to CRAN by end of the week.

# devtools::install_github("timelyportfolio/listviewer")
library(listviewer)
jsonedit(list(), elementId="my-special-unique-id")

image

other htmlwidgets

For other htmlwidgets, proper usage and implementation of elementId varies by author and timing. However after creation, you can add an elementId for other htmlwidgets by assigning an elementId after construction. Assuming I did not add the elementId argument to jsonedit, here is how we could achieve this.

# see above for better usage but here is a way to provide elementId
#    if a htmlwidget does not provide a elementId argument in the constructor function

library(listviewer)

je <- jsonedit(list())
je$elementId <- "my-special-override-id"
je

@jennybc
Copy link
Contributor Author

jennybc commented Oct 31, 2016

I was also thinking maybe I could cache that chunk? Obviously I should just try that and see what happens. But I will look forward to using elementId. Thanks!

@timelyportfolio
Copy link
Owner

Sure, thanks for using and reporting! I also added react-json as another list viewer. It is a much sparser react-based viewer. There are a couple other really nice react-based json inspectors that I also plan to add soon.

Hopefully, I can submit this to CRAN by end of day.

@jennybc
Copy link
Contributor Author

jennybc commented Oct 31, 2016

Hopefully, I can submit this to CRAN by end of day.

Is there anyway a solution for this makes it in? #18

@jennybc
Copy link
Contributor Author

jennybc commented Nov 1, 2016

I am using elementId as intended now. Does just what I hoped. Thanks.

@jennybc jennybc closed this as completed Nov 1, 2016
jennybc pushed a commit to jennybc/purrr-tutorial that referenced this issue Nov 1, 2016
@timelyportfolio
Copy link
Owner

timelyportfolio commented Nov 1, 2016

Great, thanks for the reminder. I was in such a rush last year with the widgets that I was not able to implement my checklist on all of them. Really glad you are using listviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants