Taz*_*Taz 6 r modal-dialog shiny
我想仅在模式对话框关闭时执行其余的闪亮应用程序代码。我怎样才能实现这个目标?
这里简单的代码:
# ui.R
actionButton("loadData", label = "Button", icon = icon("mail-forward"))
# server.R
observeEvent(input$loadData, {
showModal(modalDialog(
title = modal.title,
textInput("newName", "Enter file name:", value = ""),
easyClose = TRUE,
footer = list(
actionButton("confirmName", "OK"),
modalButton("Cancel"))
))
# ...code to be executed after modal is closed...
})
Run Code Online (Sandbox Code Playgroud)
创建一个事件处理程序,在单击“确定”操作按钮时执行代码,并使用 关闭模式removeModal。
library(shiny)
ui <- fluidPage(
actionButton("loadData", label = "Button", icon = icon("mail-forward")),
verbatimTextOutput("filename")
)
server <- function(input, output, session) {
observeEvent(input$loadData, {
showModal(modalDialog(
title = "title",
textInput("newName", "Enter file name:", value = ""),
easyClose = TRUE,
footer = list(
actionButton("confirmName", "OK"),
modalButton("Cancel"))
))
})
output$filename <- eventReactive(input$confirmName, {
message("Closing modal")
removeModal()
input$newName
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
文档中有一个示例:https ://shiny.rstudio.com/reference/shiny/latest/modalDialog.html