I am using a for loop to create multiple popping up messages in my shiny app (using shinyalert package). I would like messages to stop popping if user had clicked Cancel as an answer to a previous message. Below a sample of code illustrating my example
library(shiny)
library(shinyalert)
ui <- fluidPage(
actionButton("run", "Run")
)
server <- function(input, output, session) {
observeEvent(input$run, {
vector.elements <- c("A", "B", "C", "D", "E")
decision <<- TRUE
for (element in vector) {
shinyalert(
title = "Do you accept following element?",
text = element,
showCancelButton = TRUE,
callbackR = mycallback)
mycallback <- function(value) {
decision <<- value
}
if (decision == FALSE) {
break
}
}
})
}
shinyApp(ui = ui, server = server)
If user clicks on Cancel button as an answer to Do you accept following element? A, I would like next messages not to pop up.
Any hint would be much appreciated!