Hello, I'm trying to incorporate shinyalert with shiny dashboard.
Here's example code that throwing the error and the error message:
Error in match.arg(skin) : 'arg' must be NULL or a character vector
The error is coming from the dashboardPage function interpreting the "useShinyalert()" argument as the "skin" parameter in its function definition. How do I incorporate these two packages?
Thanks!
Sample Code:
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() ## <- 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
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)