Shinyalert capturing the callback

Hi All,

I should have stuck at it a bit longer before posting
Answer is below. type = 'input', is only if you want to actually type something into the message box

# Working Example
if (interactive()) {
  library(shiny)
  library(shinyalert)
  
  shinyApp(
    ui = fluidPage(
      useShinyalert(),  # Set up shinyalert
      actionButton("btn", "Click me")
    ),
    server = function(input, output) {
      observeEvent(input$btn, {
        # Show a simple modal
        shinyalert(title = "The Big Short",showCancelButton = TRUE, showConfirmButton = TRUE,
          callbackR = function(x) { if(x != FALSE) cat("Hello ", x) }
        )
      })
    }
  )
}

Created on 2018-09-26 by the reprex package (v0.2.0).

Thank you for your time

3 Likes