1

Here in attach my example piece of code that doesn't work.

If I #hide the first shinyalert, the second popup shows correctly the table.

I think the wrong behaviour depends on a IDs mismatch, but I wasn't able to write different IDs manually on the correct objects. Many thanks in advance.

library(shiny)

ui <- fluidPage(
    shinyalert::useShinyalert(),
    #action button to run the example
    mainPanel(shiny::actionButton(inputId = "elab", label = "Run the code...", class = "butt"))
)

server <- function(input, output) {
    #first popup the table appears correctly
    shiny::observeEvent(input$elab, {
        shinyalert::shinyalert(
            inputId = "sa1",
            title = "<h3>First popUp</h3>",
            type = "warning", html = TRUE, size = "l",
            text = shiny::div(id = "div1", DT::renderDataTable(DT::datatable(data = iris %>% dplyr::select(Species) %>% head(1)))
            )
        )
        print("execution after 1")

        #second popup appears whitout the table
        shinyalert::shinyalert(
            inputId = "sa2",
            title = "<h3>Second popUp</h3>",
            type = "error", html = TRUE, size = "l",
            text = shiny::div(id = "div2", DT::renderDataTable(DT::datatable(data = mtcars %>% dplyr::select(disp) %>% head(2))))
        )
        print("execution after 2")
    })

}
shinyApp(ui = ui, server = server)
  • I this this may be a [known issue](https://github.com/daattali/shinyalert/issues/48). I was able to get the code above to work using `callbackR` and putting the second `shinyalert` in the callback function, as long as I included `Sys.sleep(.5)` for a 500 msec delay befre showing the second alert. – Ben Jan 29 '22 at 16:38

0 Answers0