title: Rails 4 & Coffee Script form helper to hide on unchecked field
body: <p>I am trying to make an app in Rails 4.</p>
  
  <p>I use simple form for the form and have a js form helper file which I use to have javascript hide or show form elements depending on how users answer questions as they move through the form.</p>
  
  <p>My problem is that this js function works fine on the initial create, but if i come back to edit the form, the reminder id content is shown when the draft attribute is == false.</p>
  
  <p>Is there another way to approach this problem?</p>
  
  <p>My form has:</p>
  
  <pre><code>  &lt;%= f.simple_fields_for :scope do |finalises_s| %&gt;
        &lt;%= finalises_s.simple_fields_for :finalise do |dr| %&gt;
  
            &lt;div class="row"&gt;
              &lt;div class="col-md-3 col-md-offset-1"&gt;
  
                &lt;%= dr.label :draft, 'Would you like to save this draft and finish it later?', class: 'question-project' %&gt;
              &lt;/div&gt;
              &lt;div class="col-md-7"&gt;
                &lt;%= dr.collection_radio_buttons :draft, [[true, ' Yes, save a draft'], [false, ' No, publish it']], :first, :last, {:item_wrapper_class =&gt; 'fixradio'}, {:class =&gt; "response-project"} %&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="reminder"&gt;
              &lt;div class="row"&gt;
                &lt;div class="col-md-3 col-md-offset-1"&gt;
  
                  &lt;%= dr.label :reminder, 'Would you like a reminder to complete this draft?', class: 'question-project' %&gt;
                &lt;/div&gt;
                &lt;div class="col-md-7"&gt;
                  &lt;%= dr.collection_radio_buttons :reminder, [[true, ' Yes'], [false, ' No']], :first, :last, {:item_wrapper_class =&gt; 'fixradio'}, {:class =&gt; "response-project"} %&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>My js form-helper file has:</p>
  
  <pre><code>if $("input:radio[name='"+ inString + "[scope_attributes][finalise_attributes][draft]']").is(':checked')
    $('#reminder').show()
  else
    $('#reminder').hide()
  $(document).on 'change', "input:radio[name='"+ inString + "[scope_attributes][finalise_attributes][draft]']", ()-&gt;
    if $(this).val() == 'true'
      $('#reminder').show()
    else
      $('#reminder').hide()
  </code></pre>