Quantcast
Channel: observeEvent listen to any input with same name pattern - Stack Overflow
Viewing all articles
Browse latest Browse all 3

observeEvent listen to any input with same name pattern

$
0
0

I have a Shiny app with many inputs with similar id. There's one action that any of them should trigger. I need to dinamically refer to those input ids inside an observeEvent listener. The number of inputs is unknown, so I need a general solution. I tried to name the input with a regex, but I didn't manage to make it work. Here's an example app:

library(shiny)ui <- fluidPage(  actionButton("button_1", label = "Button 1"),  actionButton("button_2", label = "Button 2"),  actionButton("button_3", label = "Button 3"))server <- function(input, output, session) {  observeEvent((input$button_1|input$button_2|input$button_3),  { #Replace with listen to any input with id starting with "button_"    showModal(modalDialog("Thanks for pushing the button"))  }) }shinyApp(ui, server)

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>