1

我没有shinyBS在 google/SO 的文档和关于如何使用的信息中找到任何信息,trigger = 'manual'例如addPopover. shinyBS我认为这是向禁用按钮添加工具提示的方法。(我不想通过' divving 按钮和titledivshiny

4

2 回答 2

2

如果要trigger = manual在弹出框上使用,则需要定义一个脚本来切换弹出框,例如使用 jQuery:

library(shiny)
library(shinyjs)
library(shinyBS)


ui <-shinyUI(fluidPage(useShinyjs(),
                       # press this button to trigger the popover
                       actionButton("addPopover", "Add Popover"),
                       
                       # a disabled button
                       disabled(actionButton("disabledButton", "This button is disabled")),
                       
                       # the popover to appear over the disabled button
                       bsPopover("disabledButton", "Popover", "Some text", trigger="manual"),
                       
                       # the script to trigger the popover
                       uiOutput("trigger")))


server <- shinyServer(function(input,output, session){
  
  # on checkbox selection, disable button and trigger the popover
  output$trigger <- renderUI({
    input$addPopover
    tags$script("$('#disabledButton').popover('toggle');")
  })
})

shinyApp(ui,server)
于 2017-07-06T19:35:57.940 回答
-2

由于shosaco的解决方案对我不起作用,我让它以这种方式工作:

if (input$disable) { 
  addCssClass("buttonId", "disabled")
  bsTooltip("buttonId", "This button is currently disabled.")
} else {
  bsTooltip("buttonId", "")
  removeCssClass("buttonId", "disabled")
}
observeEvent(input$buttonId, {
    if (!input$disable) {
      output$text <- renderText("Bla")
    } else {
      output$text <- renderText(NULL)
    }
于 2017-07-08T23:05:00.447 回答