title: How to dynamically add a field to a form
body: <p>In my form I would like to dynamically add a field when the checkbox is checked. </p>
  
  <p>The <code>.select-qty</code> has css <code>dislpay: none</code></p>
  
  <pre><code>&lt;%= form_with model: @item,  html: { class: "update-form", method: :patch, remote: true }  do |f| %&gt;
    &lt;%= f.hidden_field :id, value: item.id %&gt;
    &lt;td class="mulitple-item"&gt;
      &lt;%= f.check_box :selected, { checked: true, value: item.selected, class: 'form-control', onchange: 'this.form.submit();' } %&gt;
   &lt;/td&gt;
   &lt;td class="select-qty&gt;
    &lt;%= f.select :quantity, options_for_select((0..item.quantity), selected: 2), {}, { value: item.quantity, class: 'form-control', onchange: 'this.form.submit();' } %&gt;
   &lt;/td&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I have this <code>update.js.erb</code>which is supposed to make the field appeared... </p>
  
  <pre><code>$('.multiple-item').bind('.update-form').bind('.submit-btn').bind('ajax:success', function(){
   $(".select-qty").css("display", "block")
  });
  </code></pre>
  
  <p>in my routes i have this: </p>
  
  <pre><code>patch "items", to: "items#update",  defaults: { format: 'js' }
  </code></pre>
  
  <p>and my controller <code>#update</code></p>
  
  <pre><code>def update
   @item = Item.find(params[:id])
       @item.update_attributes(item_params)
     respond_to do |format|
       format.js
      end
   end
  </code></pre>
  
  <p>When I check the checkbox it renders the raw code of the <code>update.js.erb</code> in the browser... </p>
  
  <p>What am I doing wrong?</p>