1

I want to control the appearance of a modalDialog depending on the input of a selectInput, what is the best way to do that? I've tried the following code, but conditionalpanel doesn't work within modalDialog. (showing part of the code)

ui<-fluidPage(
    selectInput("v1",c("Active_ingredient","Brand_Name"),
    actionButton("tabBut", "Select Drug and Event...", style='primary')
    )

server<-function(input, output, session) {

dataModal<-function(failed=FALSE){
modalDialog(
         conditionalPanel(
           condition="input.v1==Active_ingredient",
           selectizeInput_p("t1", "Active Ingredient",
                            choices=c("start typing to search..."="",ing_choices),
                            HTML( tt('drugname1') ), tt('drugname2'),
                            placement='bottom')
         ),
         conditionalPanel(
           condition="input.v1==Brand_Name",
           selectizeInput_p("t1_1", "Name of Drug",
                            choices=c("start typing to search..."="",drug_choices),
                            HTML( tt('drugname1') ), tt('drugname2'),
                            placement='bottom')
         ),
         selectizeInput_p("t2", "Adverse Events",choices= c("Start typing to search"=""), 
                          HTML( tt('eventname1') ), tt('eventname2'),
                          placement='left'),               
         numericInput_p('maxcp', "Maximum Number of Change Points", 3, 1, step=1,
                        HTML( tt('cplimit1') ), tt('cplimit2'),
                        placement='left'),

         footer = tagList(
           modalButton("Cancel"),
           actionButton("update", "OK")
         )
   )
}

         observeEvent(input$tabBut, {
         showModal(dataModal())
     })
}
Nancy Zhu
  • 40
  • 7

1 Answers1

1

You might try moving the modal dialog to ui.R, using bsModal.See here for an example:

Create a popup dialog box interactive

Hope this helps! Florian

Florian
  • 24,425
  • 4
  • 49
  • 80