我想创建一个显示当前下拉选项的弹出窗口。我的代码似乎适用于第一次单击,但第二次单击时,第一个模式出现,我无法关闭弹出窗口。示例代码粘贴在下面,任何建议都将非常感谢。
library(shinyBS)
shinyApp(
ui = basicPage(
actionButton("show", "Show modal dialog"),
uiOutput("Box1"),
uiOutput("modal")
),
server = function(session, input, output) {
observeEvent(input$show,{
output$text <- renderText(input$select1)
output$modal <- renderUI({
bsModal(paste("model", input$show, sep = ''), "Choice", "show", size = "small", textOutput("text"))
})
toggleModal(session,paste("model", input$show, sep = ''), "close")
})
output$Box1 <- renderUI({
selectizeInput("select1","Select",c("A","B","C"))
})
})
答案 0 :(得分:1)
简化代码使其有效:
shinyApp(
ui = basicPage(
actionButton("show", "Show modal dialog"),
selectizeInput("select1","Select",c("A","B","C")),
bsModal("model", "Choice", "show", size ="small", textOutput("text"))
),
server = function(session, input, output) {
output$text <- renderText(input$select1)
})