title: Bootstrap modal not closing on form submit - Rails
body: <p>I have this modal in my view:</p>
  
  <pre><code>&lt;div class="modal fade" id="addListItem" tableindex="-1" role="dialog" aria-labelledby="addListItem" aria-hidden="true"&gt;
    ......
    ......
        &lt;div class="modal-body"&gt;
           &lt;%= form_for @list_item, :remote =&gt; true, :html =&gt; {:id =&gt; "addForm"} do |f| %&gt;
               &lt;%= f.hidden_field :upc, :value =&gt; @item.upc %&gt;
               &lt;%= f.hidden_field :inventory_item_id, :id =&gt; "inventoryID", :value =&gt; "" %&gt;
               &lt;%= f.submit("Add It!", class: "btn", :id =&gt; "addSubmit") %&gt;
           &lt;% end %&gt;
        &lt;/div&gt;
    ......
    ......
  &lt;/div&gt;
  </code></pre>
  
  <p>Because the form is remote, I want this modal to hide on form submit. Here's how I do that:</p>
  
  <pre><code>$('#addForm').submit(function() {
      $('#addListItem').modal('hide');
  });
  </code></pre>
  
  <p>What's currently happening is puzzling me. When I hit submit, the form submits remotely and the modal stays open. When I hit the submit button a second time, the form submits again and the modal hides. Why is this modal not hiding on the first submit? Thanks in advance!</p>