updateAwesomeCheckbox: Change the value of an awesome checkbox input on the client

Description Usage Arguments See Also Examples

Description

Change the value of an awesome checkbox input on the client

Usage

1
updateAwesomeCheckbox(session, inputId, label = NULL, value = NULL)

Arguments

session

standard shiny session

inputId

The id of the input object.

label

The label to set for the input object.

value

The value to set for the input object.

See Also

awesomeCheckbox

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
45
46
47
48
49
## Not run: 

if (interactive()) {

library("shiny")
library("shinyWidgets")


ui <- fluidPage(
  awesomeCheckbox(
    inputId = "somevalue",
    label = "My label",
    value = FALSE
  ),

  verbatimTextOutput(outputId = "res"),

  actionButton(inputId = "updatevalue", label = "Toggle value"),
  textInput(inputId = "updatelabel", label = "Update label")
)

server <- function(input, output, session) {

  output$res <- renderPrint({
    input$somevalue
  })

  observeEvent(input$updatevalue, {
    updateAwesomeCheckbox(
      session = session, inputId = "somevalue",
      value = as.logical(input$updatevalue %%2)
    )
  })

  observeEvent(input$updatelabel, {
    updateAwesomeCheckbox(
      session = session, inputId = "somevalue",
      label = input$updatelabel
    )
  }, ignoreInit = TRUE)

}

shinyApp(ui = ui, server = server)

}


## End(Not run)

dreamRs/shinyWidgets documentation built on June 20, 2019, 7:36 a.m.