r - Shiny - how to reset/ refresh the form? -
how can refresh or reset ui/ form in shiny?
i have button in ui.r:
actionbutton("resetinput", "reset inputs")
what should in server.r reset form?
observeevent(input$resetinput, { // refresh or reset form })
i tried answer, error:
warning: error in library: there no package called ‘shinyjs’
does package exist?
any better way of doing without installing new packages?
you should put
library(shinyjs)
above server definition, missing in example referring to.
so:
library(shinyjs) library(shiny) runapp(shinyapp( ui = fluidpage( shinyjs::useshinyjs(), div( id = "form", textinput("text", "text", ""), selectinput("select", "select", 1:5), actionbutton("refresh", "refresh") ) ), server = function(input, output, session) { observeevent(input$refresh, { shinyjs::reset("form") }) } ))
i modify answer referring to include library call. hope helps!
Comments
Post a Comment