2017-04-19 88 views
2

從shinyBS發出的動態彈出窗口只會在每第二次選擇時亮起。從shinyBS閃爍的彈出式窗口僅顯示每秒第二次

library(shiny) 
library(shinyBS) 

ui <- fluidPage(
    sidebarLayout(
     sidebarPanel(
     selectInput("poppy", "Think!", c("A", "B", "C", "D")), 
     bsButton("dummy", "dummy")), ## required, dummy 
     mainPanel(
     helpText("Note that when you select from the box, popover turns up every second time only!") 
))) 

server <- function(input, output, session) { 
    observe({ 
    poppy = paste("You selected ", input$poppy) 
    addPopover(session, "poppy", "Every second time", poppy) 
})} 

shinyApp(ui = ui, server = server) 

回答

1

這是引導一個已知的bug:

Bootstrap popover destroy & recreate works only every second time

如果你不想改變ShinyBS的代碼,添加一個js文件在你的WWW子文件夾下面的:

shinyBS.addTooltip = function(id, type, opts) { 
    var $id = shinyBS.getTooltipTarget(id); 
    var dopts = {html: true}; 
    opts = $.extend(opts, dopts); 

    if(type == "tooltip") { 
    $id.tooltip("destroy"); 
    setTimeout(function() {$id.tooltip(opts);},200); 
    } else if(type == "popover") { 
    $id.popover("destroy"); 
    setTimeout(function() {$id.popover(opts);},200); 
    } 
} 

,並添加以下到您的用戶界面:(假設文件名爲pop_patch.js)

singleton(tags$head(tags$script(src = "pop_patch.js"))), 
+0

作品一種享受。只需要記住將.js文件放在www文件夾中。 –