title: Dynamically adding modules in shiny
body: <p>This isn't about creating modules using renderUI.
  With renderUI as i understand it you put a placeholder inside the UI function and then you write your controls/widget inside the server function.</p>
  
  <p>Modules come in two parts. One part you have to add to the UI function and another part to the server function using callModule(). </p>
  
  <p>I have a slider module. I want to add it to a wellpanel when an "add" action button is clicked. If it helps you can think of duplicating the module as many times i want when a button is clicked. The duplicate modules should all be independent. </p>
  
  <p>Visually</p>
  
  <p><a href="https://i.stack.imgur.com/HhB9W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HhB9W.png" alt="dynamically loading modules"></a></p>
  
  <p>I want to know how can an action button add the UI part of the module inside the UI function and server part inside the server function.
  </p>
  
  <pre><code>#Dynamically adding modules
  library(shiny)
  
  #slider module ------------------------
  sliderUI &lt;- function(id) {
    ns &lt;- NS(id)
    sliderInput(ns("bins"), "Number of Bins:", min = 1, max = 5, value = 3)
  }
  
  slider &lt;- function(input, output, session) {}
  
  
  #shiny app ------------------------
  ui &lt;- fixedPage(
    fixedRow(
      column(width = 4, wellPanel(
        h4("Slider Module"),
        sliderUI("slider"),
        actionButton("addSliderModule", "Add Slider Module"))
      ),
      column(width = 4, wellPanel(
        h4("Dynamic Loading Modules"),
        p("Clicking on the 'Add' button on the left should add the module here. You should be able to duplicate that slider module as many times as the button is clicked"),
    hr())
      )
    )
  )
  
  server &lt;- function(input, output, session) {
     observeEvent(input$addSliderModule, {
        #what goes here
     })
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>cross posted on <a href="https://groups.google.com/forum/#!topic/shiny-discuss/BMZR3_MH0S4" rel="nofollow noreferrer">shiny-group</a></p>