useShinyalert: Set up a Shiny app to use shinyalert

Description Usage Arguments Value See Also Examples

View source: R/useShinyalert.R

Description

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.

Usage

1

Arguments

rmd

Deprecated, do not use this parameter.

force

Set to TRUE to force pre-loading the shinyalert scripts. If FALSE (default), you will get a warning saying this function is not required.

Value

Scripts that shinyalert requires that are automatically inserted to the app's <head> tag.

See Also

shinyalert

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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")
      })
    }
  )
}

shinyalert documentation built on Dec. 21, 2021, 1:06 a.m.