if (interactive()) {
shiny::shinyApp(
ui = shiny::fluidPage(
useShinyjs(), # Set up shinyjs
shiny::actionButton("btn", "Click me"),
shiny::textInput("element", "Watch what happens to me")
),
server = function(input, output, session) {
shiny::observe({
if (input$btn == 0) {
return(NULL)
}
# Change the following line for more examples
toggleState("element")
})
}
)
}
# The shinyjs function call in the above app can be replaced by
# any of the following examples to produce similar Shiny apps
toggleState(id = "element")
enable("element")
disable("element")
# Similarly, the "element" text input can be changed to many other
# input tags, such as the following examples
shiny::actionButton("element", "I'm a button")
shiny::fileInput("element", "Choose a file")
shiny::selectInput("element", "I'm a select box", 1:10, selectize = FALSE)Run the code above in your browser using DataLab