Hi, can I check in my server.R if the sidebar of a shinydashboard is currently visible? Thanks Sigbert
library(shiny)
library(shinydashboard)
ui<-dashboardPage(
dashboardHeader(title = "Sidebar Test"),
dashboardSidebar(
sidebarMenu(
menuItem(text = "Some Item", tabName = 'myTab')
)
),
dashboardBody(
tags$head(tags$script("$(function(){
$('.sidebar-toggle').on('click',function(){Shiny.onInputChange('sidebarStatus',$('aside.main-sidebar.shiny-bound-input').attr('data-collapsed'))});
});
")),
tabItems(
tabItem(tabName = 'myTab',textOutput('out_text_sidebarStatus'))))
)
server <- shinyServer(function(input,output,session){
output$out_text_sidebarStatus = renderText({
if(is.null(input$sidebarStatus)){return("Opened")}
if(input$sidebarStatus=='true'){return("Opened")}
return('Closed')
})
})
runApp(shinyApp(ui=ui,server=server), launch.browser=TRUE)
OK, found myself via debugging input$sidebarCollapsed