ability: enable or disable an element

Description Usage Arguments See Also Examples

View source: R/ability.R

Description

ability is to be used to enable or disable an element. html_enable and html_disable are shortcut functions.

Usage

1
2
3
4
5

Arguments

id

shiny input id

state

logical scalar. If state is TRUE, element will be enabled, if FALSE, element will be disabled.

See Also

Other javascript functions: activate, click_event, html_class, html_toogle

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
41
42
43
44
library(shiny)
library(shinytools)

if (interactive()) {
  ui <- fluidPage(
    load_jstools(),
    fluidRow(
      column(width = 4,
             actionButton(inputId = "able_slider",
                          label = "[slider] enabled/disabled"),
             br(),br(), br(),
             sliderInput( "slider",
                          "A Number:",
                          min = 0, max = 1000, value = 500)
      ),
      column(width = 4,
             actionButton(inputId = "able_select",
                          label = "[list] enabled/disabled"),
             br(),br(), br(),
             selectizeInput("select", "A select input:", 1:5)
      ),
      column(width = 4,
             actionButton(inputId = "able_btn",
                          label = "[btn] enabled/disabled"),
             br(),br(), br(),
             actionButton("btn", "A button", class = "btn-warning")
      )
    )
  )

  server <- function(input, output) {
    observeEvent(input$able_slider, {
      ability("slider", input$able_slider%%2 < 1)
    })
    observeEvent(input$able_btn, {
      ability("btn", input$able_btn%%2 < 1)
    })
    observeEvent(input$able_select, {
      ability("select", input$able_select%%2 < 1)
    })
  }

  print(shinyApp(ui, server))
}

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