title: Cocoon callbacks after form reload
body: <p>I am creating a form where a user can add many nested questions, and each question can have many nested answers, other fields have ActiveRecord validators and when they fail, the page gets reloaded, the inserted fields are still there.</p>
  
  <p>All callbacks(such as <code>cocoon:before-insert</code>) are not reloaded, for instance a change handler of a dropdown on an inserted object</p>
  
  <p>What can I do to make these callbacks be respected if the page is reloaded on a server-side validator fail?</p>
  
  <p>On another note, what would be, code-quality wise, the best way to add handlers created inside a cocoon callback to nested objects built when the <code>new</code> method on the controller is called(i.e. objects which are not affected by after-insert/before-insert callbacks)? </p>
  
  <p>Here's some sample coffeescript code for clarification:</p>
  
  <pre><code>$(document).ready -&gt;
    $('#questions').on("cocoon:after-insert", (e, added_question) -&gt;
      added_question.find('#type').change -&gt;
        if $(this).val() is "1"
          added_question.find("#answers").hide()
        else
          added_question.find("#answers").show()
  </code></pre>
  
  <p>EDIT: changed question since removal problem was a lack of a proper wrapper-class</p>
  
  <p>EDIT #2: added sample code </p>