I have a reset (actionButton
) and update button (submitButton
) in my Shiny app. The problem is that to reset the app, I have to click on the reset
button followed by the update
button. Is it possible to reset the app without having to click on update?
In the example below, I have to click on update
twice to get the whole app to reset :
library(shiny)
shinyApp(
ui = basicPage(
numericInput("num", label = "Make changes", value = 1),
submitButton("Update", icon("refresh")),
shinyjs::useShinyjs(),
actionButton("reset", "Reset"),
helpText(
"When you click the button above, you should see",
"the output below update to reflect the value you",
"entered at the top:"
),
verbatimTextOutput("value")
),
server = function(input, output) {
# submit buttons do not have a value of their own,
# they control when the app accesses values of other widgets.
# input$num is the value of the number widget.
output$value <- renderPrint({
input$num
})
observeEvent(input$reset, {
shinyjs::reset("num")
})
}
)
I hope someone can enlighten me!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…