我想创建一个显示当前下拉选择的弹出窗口。我的代码似乎可以在第一次单击中起作用,但是当单击第二次时,出现第一个模式,我无法关闭弹出窗口。示例代码在下面粘贴,任何建议都将不胜感激。
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"))
})
})
简化代码使其起作用:
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)
})