2017-11-29 2 views
0

モーダルダイアログボックスが閉じているときだけ、光沢のあるアプリケーションコードを実行したい。どうすればこれを達成できますか?Rモーダルが閉じられるまで光沢のあるストップコードが実行される

ここでは簡単なコード:

# 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... 

}) 

答えて

0

はOKアクションボタンがクリックされたときのコードを実行event handler作成し、また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) 

この例は、ドキュメントにあります:https://shiny.rstudio.com/reference/shiny/latest/modalDialog.html

関連する問題