html_toogle: Display or hide an element

Description Usage Arguments See Also Examples

View source: R/toogle.R

Description

html_toogle will display an element if hidden or hide it if visible. html_set_visible will make an element visible. html_set_hidden will hide an element.

Usage

1
2
3
4
5
html_toogle(id, protect_id = FALSE)

html_set_visible(id, protect_id = FALSE)

html_set_hidden(id, protect_id = FALSE)

Arguments

id

shiny input id

protect_id

wether to process shiny input id with function session$ns() or not.

See Also

Other javascript functions: ability, activate, click_event, html_class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(shinytools)

if (interactive()) {
  options(device.ask.default = FALSE)

  ui <- fluidPage(
    titlePanel("Hello dghiesse!"),
    load_jstools(),
    sidebarLayout(
      sidebarPanel(
        sliderInput( "obs",
          "Number of observations:",
          min = 0, max = 1000, value = 500),
        actionButton("toogle", "toogle"),
        actionButton("set_visible", "show"),
        actionButton("set_hidden", "hide")
      ),
      mainPanel(
        plotOutput("distPlot")
      )
    )
  )

  server <- function(input, output) {
    output$distPlot <- renderPlot({
      hist(rnorm(input$obs))
    })
    observeEvent(input$toogle, {
      html_toogle("distPlot")
    })
    observeEvent(input$set_visible, {
      html_set_visible("distPlot")
    })
    observeEvent(input$set_hidden, {
      html_set_hidden("distPlot")
    })
  }

  print(shinyApp(ui, server))
}

ardata-fr/shinytools documentation built on Nov. 15, 2019, 7:53 p.m.