2016-05-23 22 views
0

有沒有一種方法可以禁用tabPanel直到單擊actionButton?我試圖用shinyjs做到這一點,但沒有奏效。目前我的ui.R有以下代碼。我想禁用'過濾'tabPanel直到loadButton被點擊。 `如何禁用shinydashboard中的tabPanel?

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") 
     )) 

` 任何幫助表示讚賞。

回答

1

我得到它與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'); 
} 

「 ` 然後啓用和禁用所需選項卡。