Shiny 将pickerInput下拉列表放置在confirmSweetAlert按钮的前面
我试图将pickerInput下拉列表放在confirmSweetAlert按钮前面,但在CSS中使用z-index似乎不起作用。还有其他建议吗Shiny 将pickerInput下拉列表放置在confirmSweetAlert按钮的前面,shiny,shinywidgets,Shiny,Shinywidgets,我试图将pickerInput下拉列表放在confirmSweetAlert按钮前面,但在CSS中使用z-index似乎不起作用。还有其他建议吗 library(shiny) library(shinyWidgets) ui <- fluidPage( actionButton( inputId = "launch", label = "Launch Confirm!" ) ) server <- function
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
actionButton(
inputId = "launch",
label = "Launch Confirm!"
)
)
server <- function(input, output, session) {
# Launch sweet alert confirmation
observeEvent(input$launch, {
confirmSweetAlert(
session = session,
inputId = "test",
title = "This is a Test!",
type = "info",
text = tags$div(
div(style="position: relative; z-index: 1;", pickerInput(
inputId = "numbers",
multiple = TRUE,
choices = 1:5,
width = "100%"
)),
closeOnClickOutside = FALSE,
html = TRUE
))
})
}
if (interactive())
shinyApp(ui, server)
库(闪亮)
图书馆(shinyWidgets)
ui您可以在pickerInput
中使用options=pickerOptions(container=“body”)
将选择附加到特定元素,在这种情况下,“body”
帮助定位菜单
完整示例:
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
actionButton(
inputId = "launch",
label = "Launch Confirm!"
)
)
server <- function(input, output, session) {
# Launch sweet alert confirmation
observeEvent(input$launch, {
confirmSweetAlert(
session = session,
inputId = "test",
title = "This is a Test!",
type = "info",
text = tags$div(
pickerInput(
inputId = "numbers",
multiple = TRUE,
choices = 1:5,
width = "100%",
options = pickerOptions(container = "body")
),
closeOnClickOutside = FALSE,
html = TRUE
))
})
}
if (interactive())
shinyApp(ui, server)
库(闪亮)
图书馆(shinyWidgets)
非常感谢!另请参阅以获取其他解决方案。