[英]add shinyBS popover on disabled button
我沒有在shinyBS
的文檔和 google/SO 上找到任何關於如何在addPopover
的shinyBS
上使用trigger = 'manual'
的信息。 我認為這將是向禁用按鈕添加工具提示的方法。 (我不想通過div
'ving the button 並將title
賦予div
來做到這一點。如果有人有辦法將工具提示反應性地添加到shiny
的應用程序,那也很好
如果你想在彈出窗口上使用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)
由於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)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.