I am building an app where the user is greeted by a landing page. Upon clicking an actionButton
I wish for the user to be moved to a different menuItem
and for the landing page to be hidden. shinyjs::hide()
seems perfect for this purpose, but I can't seem to get the function to accept the name of the menuItem
in question as the ID for the object to be hidden.
library(shiny)
library(shinydashboard)
library(shinyjs)
## UI ##
ui <- dashboardPage(
skin = "black",
dashboardHeader(
title = "Template"
),
dashboardSidebar(
sidebarMenu(id = "sidebarmenu",
menuItem("Landingpage", tabName = "landing", icon = icon("cog")),
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
)
),
dashboardBody(
useShinyjs(),
tabItems(
tabItem(tabName = "landing",
h2("Landing Page"),
actionButton(inputId = "confirm",
label = "Confirm",
icon = icon("ok-circle"))
),
tabItem(tabName = "dashboard",
h2("Dashboard Content")
)
)
)
)
## Server ##
server <- function(input, output, session) {
observeEvent(input$confirm, {
shinyjs::hide(id = "landing")
updateTabItems(session, "sidebarmenu", "dashboard")
})
}
shinyApp(ui, server)
Here's my most recent attempt. Am I going about this the wrong way? Is shinyjs::hide()
even the proper way of doing this?