1

I would like to create a popup that displays the current dropdown choice. My code seems to work for the first click, but when clicked a second time, the first modal appears, and I am unable to close the popup. Example code is pasted below, and any suggestions would be greatly appreciated.

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"))
})

})
Jamie
  • 110
  • 2
  • 8

1 Answers1

2

Simplifying the code makes it work:

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)
  })
HubertL
  • 19,246
  • 3
  • 32
  • 51