I would like to hide/show a tabpanel given certain conditions. When selecting "source 2", I would like to hide tab2, but the code that I used have a bug. If I first selected "source 1", and then clicked "tab2", and changed the data source to "source 2", the "tab2" tabpanel indeed hided, but the content of "tab2" covered the contents of "tab1". How can I remove the resudual of the hided tab? Any thoughts would be highly appreciated.
library(shiny)
library(shinyjs)
runApp(list(
ui = fluidPage(
useShinyjs(),
selectInput('dataSource',h5("Please choose the data source:"), c("source 1", "source 2"), "source 1"),
tabsetPanel(
id = "navbar",
tabPanel(title = "tab1",
value = "tab1",
h1("Tab 1")
),
tabPanel(id="id2", title = "tab2",
value = "tab2",
h1("Tab 2")
)
)
),
server = function(input, output) {
observeEvent(input$dataSource,{
toggle(condition = (input$dataSource !='source 2'), selector = "#navbar li a[data-value=tab2]")
})
}
))
[the bug looks like this][1] [1]: http://i.stack.imgur.com/eOHLS.png