Question
Why does a sliderInput() that's generated on the server, and rendered on the ui with uiOutput() not get displayed in a menuItem()?
Example
In this simple app I'm generating a sliderInput on the server (note the menuItem is deliberately commented out), and it works as expected
library(shiny)
library(shinydashboard)
rm(ui, server)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
#menuItem(text = "data options",
checkboxGroupInput(inputId = "cbg_group1", label = "group 1",
choices = c("some","check","boxes","to","choose","from") ),
uiOutput("sli_val1"),
checkboxGroupInput(inputId = "cbg_group2", label = "group 2",
choices = c("another","set","of","check","boxes") ),
# ),
menuItem(text = "another tab")
)
),
dashboardBody()
)
server <- function(input, output, session){
withProgress(message = "loading page", value=0.1, {
## simulate loading some data
Sys.sleep(3)
## slider input
output$sli_val1 <- renderUI({
sliderInput(inputId = "sli_val1",
label = "values", min = 0, max = 100,
value = c(25, 75) )
})
setProgress(value=1, detail="Complete")
})
}
shinyApp(ui = ui, server = server)
However, when I move the uiOutput inside a menuItem( ), the output no longer renders:
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem(text = "data options",
checkboxGroupInput(inputId = "cbg_group1", label = "group 1",
choices = c("some","check","boxes","to","choose","from") ),
uiOutput("sli_val1"),
checkboxGroupInput(inputId = "cbg_group2", label = "group 2",
choices = c("another","set","of","check","boxes") )
),
menuItem(text = "another tab")
)
),
dashboardBody()
)