Hi everyone,
I want to lanch a modalDialog when select different choice in a selectinput. But the modalDialog won't be displayed if you select choice which is same as old one.
I have known that react won't be triggered if input don't change the value. Is there any method to solve the issue ?
library(shiny)
ui=fluidPage(
uiOutput("output1")
)
server= function(input,output,session) {
choices <- reactiveVal(c("none","age","gender","work","so no"))
output$output1<-renderUI({
selectInput("select1","label",choices = choices())
})
observeEvent(input$select1,{
switch(input$select1,
"age"= {
showModal(modalDialog(fluidPage({}),title = "Some age settings"))
},
"gender"= {
showModal(modalDialog(fluidPage({}),title = "Some gender settings"))
}
)
})
}
shinyApp(ui=ui,server = server)
Normally, the issue solved in basic javescript is to setting it to default value in onclick event. However, updateSelect input in onclick function of "shinyjs" will close the dropdown of selectinput so it can't be select anymore.
library(shiny)
library(shinyjs)
ui=fluidPage(
useShinyjs(),
uiOutput("output1")
)
server= function(input,output,session) {
choices <- reactiveVal(c("none","age","gender","work","so no"))
output$output1<-renderUI({
selectInput("select1","label",choices = choices())
})
observeEvent(input$select1,{
switch(input$select1,
"age"= {
showModal(modalDialog(fluidPage({}),title = "Some age settings"))
},
"gender"= {
showModal(modalDialog(fluidPage({}),title = "Some gender settings"))
}
)
})
onclick("select1",{
updateSelectInput(session = session,"select1",selected = "none")
})
}
shinyApp(ui=ui,server = server)
Can you give me some tips
Thanks,
DY