title: Ajax and bootstrap modal
body: <p>I am trying to make an ajax call to delete a user making use of a bootstrap modal.
  The modal is used for confirmation purposes and it is the following.</p>
  
  <pre><code>&lt;!-- Modal --&gt;
  &lt;div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"&gt;
  &lt;div class="modal-header"&gt;
  &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
  &lt;h3 id="myModalLabel"&gt;Delete user&lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="modal-body"&gt;
  &lt;p&gt;You are about to delete this user. Are you sure that you want to continue?&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class="modal-footer"&gt;
  &lt;button id="confirm" class="btn btn-primary"&gt;Yes&lt;/button&gt;
  &lt;button id="cancel" class="btn" data-dismiss="modal" aria-hidden="true"&gt;No, leave&lt;/button&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Then I am using the following javascript to process the user input</p>
  
  <pre><code>    $('a#delete').click(function(e){
          var anchor = this;
          $('#deleteModal').modal('show');
          $('button#confirm').click(function(e){
              $('#deleteModal').modal('hide');
              $.ajax({
                  url: $(anchor).attr('href'),
                  success:function(result){
                      $(anchor).closest('tr').addClass("error");
                      $(anchor).closest('tr').delay(2000).fadeOut();
                }});
          });
          return false;
      });
  </code></pre>
  
  <p>The link that user has to click is like this</p>
  
  <pre><code>&lt;a id="delete" href="/admin/edit/user/delete/30" class="btn btn-danger" user="30"&gt;&lt;i class="icon-trash"&gt;&lt;/i&gt; Delete&lt;/a&gt;
  </code></pre>
  
  <p>It works but I noticed that something weird happens. If I click to delete one user and I choose to cancel the action from the modal and then I choose to delete another user confirming the action, both users are deleted.</p>
  
  <p>I think that the rule I have declared still applies in the objects that have been clicked during a session. Is there a way to avoid this?</p>