I am struggling with a weird behavior of shinyBS
-popovers within insertUI()
. It seems like the popover is only added if a bsButton()
is included somewhere.
You can play around with the example below. As soon as you uncomment any bsButton(...)
, the popover works.
library(shinyBS)
library(shiny)
library(shinyWidgets)
# UI ---------------------------------------------------------------------------
ui <- basicPage(
actionButton("show", "Create Input"),
# uncomment me!
# shinyBS::bsButton("id_button1", "A Button"),
fluidRow(
tags$div(id = 'placeholder',
style = "min-height: 400px;")
)
)
# Server -----------------------------------------------------------------------
server <- function(input, output, session) {
# insert checkbox when clicked
observeEvent(input$show, {
insertUI(selector = '#placeholder',
ui = tags$div(id = "id_div",
# uncomment me!
# shinyBS::bsButton("id_button2", "A Button"),
shinyWidgets::prettyCheckbox(
inputId = "id_checkbox",
label = "Click Me!"
)),
immediate = TRUE)
addPopover(session, "id_div", "Hello", "Stranger")
})
}
shinyApp(ui, server)