title: How to observe dynamically rendered ui
body: <p>So, you solve one problem and run into the next. </p>
  
  <p>I've now succesfully build a part of code that dynamically creates uiOutput, i.e. a number of sliders, buttons and/or textfields and the amount of them depends on a value that comes rolling out of my model in an ealier step. </p>
  
  <p>However, I'm pretty clueless how to observe whether they are "clicked" / "changed" by the user. Lets say, the model gives out a nr 12
  then the server tells my ui to make 12 buttons. 
  I want to know when the user pushes ANY of the buttons and WHICH button it is</p>
  
  <p>To give a clear example in words: if user clicks button 8, i want to have R tell me "User clicked button 8". 
  The objective is to have not only dynamic buttons, but also dynamic reactions to the use of them. </p>
  
  <p>One of the final aims I have is to collect a list of yes / no answers and entered names for each of the  elements. So I'm looking for a universal way to hang conditions to observeevent for button " i" or text field "j" and so on </p>
  
  <p>Here is a fully functional minimal example of how I create the dynamic UI. </p>
  
  <p>SERVER: </p>
  
  <pre><code>shinyServer = function(input, output, session) {
  
    ################# start functionality HOME TAB #############################  
  
    values &lt;- reactiveValues()
  
    observeEvent(input$myNr, { 
      values$nrofelements &lt;- input$myNr  })  
  
  
    observeEvent(values$nrofelements, {
      if (values$nrofelements &gt; 0 &amp; values$nrofelements &lt; 25) { 
      output$sliders &lt;- renderUI({
        lapply(1:values$nrofelements, function(j) {
          sliderInput(inputId = paste0("ind", j), label = paste("Individual", j),
                      min = 0, max = 20000, value = c(0, 500), step = 100)
  
        })
      })
      output$buttons &lt;- renderUI({
        lapply(1:values$nrofelements, function(i) {
          div(br(),bsButton(inputId = paste0("indr", i), label = paste("Yes", i), block = FALSE, style = "succes"), br(), br() )
  
        })
  
      })
      }  
    })
  
    observe({
      if(values$nrofelements != ""){
        for(nr in 1:values$nrofelements){
      if(!is.null(input[[paste0("indr", nr)]])) print(paste0("Inputname 'indr", nr, "': ", "value is ", isolate(input[[paste0("indr", nr)]])))       
        }
      }
  
  
     })
  
     }
  </code></pre>
  
  <p>and the UI.r </p>
  
  <pre><code>library(shiny)
  
      library(shinydashboard)
     library(shinybs)
  
  
  
  
  
  ui &lt;- dashboardPage(
    dashboardHeader(title = "FLOW C.A.R.S."),
    dashboardSidebar(
      sidebarMenu(id = "tabs", menuItem("Home", tabName = "Home", icon = icon("book"))
      )
    ),
  
    dashboardBody(
  
  tabItems(
  
    ### HOME ###_________
    tabItem(tabName = "Home",  class = 'rightAlign',
  
            h5("Enter desired nr of elements here"),
            textInput(inputId ="myNr", label = NULL , placeholder = NULL),
  
            fluidRow(
              column(3,
                     uiOutput("sliders")),
              column(1,
                     uiOutput("buttons")
              )
            ),
  
            textOutput('clickedwhat')
            )
  
  
     )
    )
  )
  </code></pre>