首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用时添加shinyBS弹出按钮

禁用时添加shinyBS弹出按钮
EN

Stack Overflow用户
提问于 2017-07-06 18:55:35
回答 2查看 1.1K关注 0票数 1

我在shinyBS的文档和google/SO上没有找到任何关于如何在addPopover of shinyBS上使用trigger = 'manual'的信息。我认为这将是向禁用的按钮添加工具提示的方法。(我不想让div按下按钮,然后把title交给div。如果有人能给shiny应用程序添加工具提示,那就更好了

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-07-09 07:05:00

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

代码语言:javascript
复制
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)
    }
票数 -2
EN

Stack Overflow用户

发布于 2017-07-07 03:35:58

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

代码语言:javascript
复制
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)
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44946974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档