View source: R/useShinyalert.R
useShinyalert | R Documentation |
This function is no longer required.
The first time a {shinyalert} message is shown, the required scripts are
automatically inserted to the Shiny app. Usually this is not an issue, but
in some unique cases this can sometimes cause the modal to appear glitchy
(such as inside RStudio's Viewer, on some old browsers, or if the modal contains
certain Shiny inputs).
If you notice issues with the UI of the modal, you may want to try to pre-load
the scripts when the Shiny app initializes by calling useShinyalert(force=TRUE)
anywhere in the UI.
useShinyalert(rmd, force = FALSE)
rmd |
Deprecated, do not use this parameter. |
force |
Set to |
Scripts that shinyalert
requires that are automatically
inserted to the app's <head>
tag.
shinyalert
if (interactive()) {
library(shiny)
library(shinyalert)
shinyApp(
ui = fluidPage(
useShinyalert(force = TRUE), # Set up shinyalert
actionButton("btn", "Click me")
),
server = function(input, output) {
observeEvent(input$btn, {
# Show a simple modal
shinyalert(title = "You did it!", type = "success")
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.