内联时如何禁用checkboxGroupInput中的各个框?

时间:2018-08-21 21:32:42

标签: javascript r shiny

所以我一直在努力尝试这项工作。我有一个闪亮的应用程序,由于某些未公开的原因,我需要能够禁用一个复选框组的各个框。我知道该帖子without inline。我真的只需要知道该怎么做。他们使用的示例是

library(shiny)

ui <- shinyUI(fluidPage(
shinyjs::useShinyjs(),
#original checkbox group
checkboxGroupInput("a","A",choices = 1:7),
#additional checkbox group to identify how to work around multiple groups
checkboxGroupInput("b","B",choices = 1:7)
))

server <- shinyServer(function(input, output, session) {

 #initialize reactive values (will use to store selected boxes to identify 
 newest selection)
 rv <- reactiveValues()
 #initialize selected boxes to NULL
 rv$selectedBoxes <- NULL 

observeEvent(input$a, {
  #extract newest selection by identifying which values are in a that have not been previously selected
  newSelection <- input$a[which(!(input$a %in% rv$selectedBoxes))]

  #create object that identifies newly selected checkbox (syntax found using selectorgadget)
  subElement <- paste0("#a .checkbox:nth-child(", newSelection,") label")

  #disable single checkbox of group
  shinyjs::disable(selector=subElement)

  #store all selected checkboxes
  rv$selectedBoxes <- input$a
  })
})

shinyApp(ui,server)

这有效,但不适用于内联。我已经尝试将.checkbox更改为.checkbox-inline,但无济于事。任何建议表示赞赏。

0 个答案:

没有答案