Learn R Programming

dqshiny (version 0.0.3)

hide: Change the state of a shiny interface element

Description

Those functions can be used to change an elements visibility status.

Usage

hide(ids)

show(ids)

toggle(ids, condition = NULL)

Arguments

ids

Character vector, id(s) of the element to hide/show.

condition

Condition to be used for toggling the visibility (TRUE = visible).

See Also

Other js handler: add_class, enable

Examples

Run this code
# NOT RUN {
## Only run examples in interactive R sessions
if (interactive()) {

library(shiny)
shinyApp(
  ui = fluidPage(
    init(),
    actionButton("hide", "Hide"),
    actionButton("show", "Show"),
    actionButton("toggle", "Toggle"),
    actionButton("toggle_cond", "Toggle Visibility with Condition"),
    actionButton("toggle_all", "Toggle All Visibilities"),
    checkboxInput("condition", "Visible"),
    actionButton("example1", "EXAMPLE1"),
    actionButton("example2", "EXAMPLE2"),
    actionButton("example3", "EXAMPLE3")
  ),
  server = function(input, output) {
    observeEvent(input$hide, hide("example1"))
    observeEvent(input$show, show("example1"))
    observeEvent(input$toggle, toggle("example1"))
    observeEvent(input$toggle_cond,
      toggle("example1", input$condition)
    )
    observeEvent(input$toggle_all,
      toggle(c("example1", "example2", "example3"))
    )
  }
)

}
# }

Run the code above in your browser using DataLab