Reputation: 419
I am using the example from Dean's shinyalert
package:
library(shiny)
library(shinyalert)
shinyApp(
ui = fluidPage(
useShinyalert(), # Set up shinyalert
actionButton("btn", "Greet")
),
server = function(input, output) {
observeEvent(input$btn, {
shinyalert(
"Enter your name", type = "input",
callbackR = function(x) { message("Hello ", x) },
callbackJS = "function(x) { alert('Hello ' + x); }"
)
})
}
)
For some reason, the example shown on the github does not work on mine. And when I remove the callbackJS. Nothing happens. I input the name and click 'Ok' but the chain modal does not work.
Any ideas?
Upvotes: 1
Views: 1854
Reputation: 17699
I think you have to use:
callbackR = function(value) { shinyalert(paste("Welcome", value))}
It might also been what is shown in the docu: https://github.com/daattali/shinyalert#chaining.
Your code message("Hello ", x)
, actually works as designed since it prints the message to the console.
Full code would read:
library(shiny)
library(shinyalert)
shinyApp(
ui = fluidPage(
useShinyalert(), # Set up shinyalert
actionButton("btn", "Greet")
),
server = function(input, output) {
observeEvent(input$btn, {
shinyalert(
"Enter your name", type = "input",
callbackR = function(value) { shinyalert(paste("Welcome", value))},
callbackJS = "function(x) { alert('Hello ' + x); }"
)
})
}
)
Upvotes: 2