Closed assignUser closed 2 years ago
This does not work for me.
library(shiny)
ui <- fluidPage(
shinyjs::useShinyjs(),
radioButtons("test", "test", c("a","b"), selected=character(0)),
actionButton("reset","reset")
)
server <- function(input, output, session) {
observeEvent(input$reset, {
shinyjs::reset("test")
})
}
shinyApp(ui, server)
The reset button does not reset the radio button. Does this code work for you?
Yes:
You are using shinyjs::
did you do devtools::install()
before? If so maybe you need to reload shinyjs/restart the session?
That's a good question, but yes I am using the version that I modified. The only thing is maybe our shiny versions aren't the same? I'm on 1.5.0
I actually get a javascript error when I try to reset to selected(0)
now (I don't get the error when resetting to a value, or before this modification)
I got the error on both chrome and firefox.
Do you have access to another machine , perhaps a cloud server, where you can test and see if you also get my issue?
Oh I think the issue is that I'musing the CRAN version of shiny, and this essentially calls shiny's function for updating radio buttons which didn't work until the new dev version, which I don't have.
I don't want to cause javascript errors in the console that didn't exist before, that for me would be an unacceptable regression. So how about we check for the shiny version and only add your code is shiny is new enough?
Ah yes that makes sense. I added a check for that.
Thanks! I'll wait until the new shiny version is in CRAN and then merge
A little late, but I finally remembered to add this in! Tested and works , thanks
Fixes #85 I have tested the changes on the example code and in my own app, everything looks fine.