-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathupdateAwesomeRadio.R
55 lines (44 loc) · 1.13 KB
/
updateAwesomeRadio.R
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
50
51
52
53
54
55
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
awesomeRadio(
inputId = "radio",
choices = c("A", "B", "C"),
label = "My label"
),
verbatimTextOutput(outputId = "res"),
actionButton(inputId = "updatechoices", label = "Random choices"),
textInput(inputId = "updatelabel", label = "Update label"),
selectInput(
inputId = "updatestatus",
label = "Status",
choices = c("primary", "danger", "warning", "success", "info")
)
)
server <- function(input, output, session) {
output$res <- renderPrint({
input$somevalue
})
observeEvent(input$updatechoices, {
updateAwesomeRadio(
inputId = "radio",
choices = sample(letters, sample(2:6, 1))
)
})
observeEvent(input$updatelabel, {
updateAwesomeRadio(
inputId = "radio",
label = input$updatelabel
)
}, ignoreInit = TRUE)
# To update status you need to provide coices too
observeEvent(input$updatestatus, {
updateAwesomeRadio(
inputId = "radio",
choices = c("A", "B", "C"),
status = input$updatestatus
)
}, ignoreInit = TRUE)
}
if (interactive())
shinyApp(ui = ui, server = server)