I need to set up different links n my first panel to open the other panels (tabItem
) using shinydashboard
and in addition of the sidebar menuItem
. For this the function updateTabItems
should do the job!
I have tried different options and look many times at the examples and answers on this subject - including Linking to a tab or panel of a shiny app and Set relative link / anchor in R Shiny
I can not figure out why the reprex below does not work (aka links are inactive)? -
Thanks in advance for the hint!
library(shiny)
library(shinydashboard)
ui <- tagList(
dashboardPage(
dashboardHeader(title = "Reprex"),
dashboardSidebar(sidebarMenu(
menuItem(" Story ", tabName = "Stories"),
menuItem( "Categories", tabName = "categories" ),
menuItem( "Origin", tabName = "origin")
)
),
dashboardBody(
shinydashboard::tabItems(
shinydashboard::tabItem(tabName = "Stories",
tags$ol(tags$li( actionLink(inputId = "linkcategories",
label = "categories") ),
tags$li( actionLink(inputId = "linkorigin",
label = "origin") )
) ) ,
shinydashboard::tabItem(tabName = "categories", " blablablablablablabla"),
shinydashboard::tabItem(tabName = "origin", " blablablablablablabla")
)
)
)
)
server <- function(input, output, session) {
## Get links to tab
observeEvent(input$linkcategories, {
shinydashboard::updateTabItems(session, "tabs", selected = "categories")
})
observeEvent(input$linkorigin, {
shinydashboard::updateTabItems(session, "tabs", selected = "origin")
})
}
shinyApp(ui, server)