2017-11-29 5 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