我正在与shinyBS
-popovers 内的奇怪行为作斗争insertUI()
。似乎只有在bsButton()
某处包含 a 时才会添加弹出框。
您可以使用下面的示例。只要您取消注释 any bsButton(...)
,弹出框就会起作用。
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)