有没有办法在单击 actionButton 之前禁用 tabPanel?我尝试使用shinyjs来做到这一点,但没有奏效。目前我的 ui.R 有以下代码。我想禁用“过滤器”tabPanel,直到单击 loadButton。
`
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")
))
`
任何帮助表示赞赏。
最佳答案
我得到它与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');
}
”
`
然后根据需要启用和禁用选项卡。
关于r - 如何禁用shinydashboard中的tabPanel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37382091/