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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -