我在shinyBS的文档和google/SO上没有找到任何关于如何在addPopover of shinyBS上使用trigger = 'manual'的信息。我认为这将是向禁用的按钮添加工具提示的方法。(我不想让div按下按钮,然后把title交给div。如果有人能给shiny应用程序添加工具提示,那就更好了
发布于 2017-07-09 07:05:00
由于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-07 03:35:58
如果要在弹出窗口上使用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)https://stackoverflow.com/questions/44946974
复制相似问题