observeEvent is not responding to selectInput

Hi,

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:
selectInput("label",
"Select Label:",
choices = c("select variable" = "0"),
selected = "0")

and the observeEvent:

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

Thanks for your help.
Is

This reprex works fine for me:

library(shiny)
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:
Cheers,
Is

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