forked from daattali/advanced-shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
27 lines (22 loc) · 775 Bytes
/
app.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
library(shiny)
library(shinyjs)
source("update-input.R")
ui <- fluidPage(
useShinyjs(),
extendShinyjs("www/app-shinyjs.js", functions = c("getInputType")),
textInput("text", "Text input", "some text"),
selectInput("select", "Select input", LETTERS),
numericInput("numeric", "Numeric input", 5),
actionButton("btn", "Update text to 'new value', select to 'G', and number to '9'", class = "btn-primary")
)
server <- function(input, output, session) {
observeEvent(input$btn, {
newValues <- list("text" = "new value",
"select" = "G",
"numeric" = 9)
updateShinyInputs(session, newValues)
# OR one by one
# updateShinyInput(session, "text", "new value")
})
}
shinyApp(ui = ui, server = server)