observeEvent is not responding to selectInput


I'm working on an app that requires an observeEvent for a selectInput. My issue is that when I click on the selectInput to show the drop down list, the event is not triggered.

My code is very basic, here are the snippets in question:
"Select Label:",
choices = c("select variable" = "0"),
selected = "0")

and the observeEvent:

ignoreInit = TRUE,
{print("Event for model label variable selection")})

Thanks for your help.

This reprex works fine for me:

ui <- fluidPage(
  selectInput("label", "Select Label:", choices = letters)
server <- function(input, output, session) {
  observeEvent(input$label, {
    message("Label changed to ", input$label)
shinyApp(ui, server)

I suspect your problem is that you only have one value, so that the value, and hence input$label, never changes.

Thanks Hadley.
Yes, you are right. It was because it has a single value. I dealt with it as "onClick" type of event in other programming language :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.