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

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -