问题
Is there a way to disable a tabPanel until an actionButton is clicked? I tried to do this using shinyjs but that did not work. Currently my ui.R has the following code. I want to disable 'Filter' tabPanel until loadButton is clicked. `
body <- dashboardBody(
useShinyjs(),
tabsetPanel(id = "tabs", type = 'pills',
tabPanel("Load", dataTableOutput("loadTab")),
tabPanel("Filter", id='filterTab',dataTableOutput("filteredResults"))
))
sidebar <- dashboardSidebar(
sidebarMenu(
selectInput(inputId = "datasetName",label = 'Dataset', choice=c('Cancer','Normal')),
actionButton("loadButton", label = "Load")
))
` Any help is appreciated.
回答1:
I got it working with shinyjs. `
jsCode <- "
shinyjs.disableTab = function() {
var tabs = $('#tabs').find('li:not(.active) a');
tabs.bind('click.tab', function(e) {
e.preventDefault();
return false;
});
tabs.addClass('disabled');
}
shinyjs.enableTab = function(param) {
var tab = $('#tabs').find('li:not(.active):nth-child(' + param + ') a');
tab.unbind('click.tab');
tab.removeClass('disabled');
}
" ` And then enabling and disabling tabs as needed.
来源:https://stackoverflow.com/questions/37382091/how-to-disable-a-tabpanel-in-shinydashboard