-
-
Save hadley/8d9ee5ea7991b0e5c400320abb9468de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modalContinue <- function(id) { | |
ns <- NS(id) | |
showModal(modalDialog( | |
"This is really important!", | |
"Are you sure you want to continue?", | |
footer = list( | |
actionButton(ns("yes"), "yes"), | |
actionButton(ns("no"), "no") | |
), | |
easyClose = FALSE | |
)) | |
} | |
modalContinueServer <- function(id) { | |
module <- function(input, output, session) { | |
val <- reactiveVal(NULL) | |
observeEvent(input$yes, { | |
removeModal() | |
val(TRUE) | |
}) | |
observeEvent(input$no, { | |
removeModal() | |
val(FALSE) | |
}) | |
reactive(val()) | |
} | |
callModule(module, id) | |
} | |
# ------------------------------------------------------------------------- | |
ui <- fluidPage( | |
actionButton("go", "Go"), | |
textOutput("result") | |
) | |
server <- function(input, output, session) { | |
observeEvent(input$go, { | |
modalContinue("ok") | |
}) | |
result <- modalContinueServer("ok") | |
output$result <- renderText(result()) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment