如何关闭嵌入式modalDialog

时间:2018-01-26 15:53:30

标签: r shiny modal-dialog

我将modalDialog嵌入到其他modalDialog中。当我运行modalButton时,它们都关闭了。 如何仅关闭嵌入式modalDialog

现在:enter image description here 代码:

library(shiny)

shinyApp(
  ui <- fluidPage(
    actionButton("one","Press")  
  ),
  server <- function(input, output,session) {
    observeEvent(input$one,{
      showModal(modalDialog(            
        actionButton("two","Press 2"),
        footer = tagList(
          modalButton("Cancel")
        )))
    })
    observeEvent(input$two,{
      showModal(modalDialog(
        "OKAY",
        footer = tagList(
          modalButton("Cancel")
        )))
    })
})

需要: enter image description here

1 个答案:

答案 0 :(得分:1)

我不确定您想要以模态显示什么,但也许您可以查看sweetalertR包:

 library(shiny)
library(sweetalertR)
shinyApp(
  ui <- fluidPage(
    sweetalert('#one',
      title = "Are you sure?",
      text = "Press here for some magic",
      type = "warning",
      showCancelButton = TRUE,
      confirmButtonColor = '#DD6B55',
      confirmButtonText = 'Yes, Confirm!',
      closeOnConfirm = FALSE,
      evalFunction = 'function(){swal("OKAY!", "Thank you PorkChop!", "success")}'
    ),
    actionButton("one","Press")  
  ),
  server <- function(input, output,session) { })

enter image description here