首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将pickerInput下拉菜单放在confirmSweetAlert按钮前面

将pickerInput下拉菜单放在confirmSweetAlert按钮前面
EN

Stack Overflow用户
提问于 2021-04-08 09:39:21
回答 1查看 128关注 0票数 1

我试图将索引下拉菜单放在confirmSweetAlert按钮的前面,但是在pickerInput中使用z-index似乎不起作用。还有其他建议吗?

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-08 18:44:25

您可以在pickerInput中使用options = pickerOptions(container = "body")将select附加到特定元素,在这种情况下,"body"帮助定位菜单。

完整示例:

代码语言:javascript
复制
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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66996246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档