Calling useShinyjs() and useShinyalert() within dashboardBody() will works.
I know that the documentation states "This function must be called from a Shiny app's UI in order for the shinyalert function to work. You can call useShinyalert() from anywhere inside the UI." which is quite confusing. Maybe the document has to be updated?
However, below is the updated example:
library(shiny)
library(shinydashboard)
library(shinythemes)
library(shinyjs)
library(shinyalert)
library(dashboardthemes)
## user function
ui <- dashboardPage(
header=dashboardHeader(title="Example App"),
sidebar=dashboardSidebar(collapsed=F),
body=dashboardBody(
shinyDashboardThemes(theme = "boe_website")
,actionButton("on_btn",label="Test 'shinyalert' Button")
,textOutput("status")
,useShinyjs()
,useShinyalert()
)
#,useShinyjs()
#,useShinyalert() ## <- error here on run app !!!
)## end user function
server <- function(input, output, session){
observeEvent(input$on_btn,{
shinyalert("Button Pushed", "Proceed?", type = "success",showCancelButton = TRUE, showConfirmButton = TRUE)
output$status <- renderText({"Button Pushed"})
},ignoreInit = T)
}## end server function
shinyApp(ui = ui, server = server)