title: Rails custom Twitter Bootstrap modal for delete method, Problem with callback
body: <p>Following code does destroy records as intended, but the callback is inherited from one modal to the next one. So while a record is properly deleted, Rails keeps looking to delete the formerly deleted ones as well.
  I'm using a Twitter Bootstrap modal window, that sits in a Rails view template and is shown when a standard Rails delete method is fired, replacing the regular javascript dialog.</p>
  
  <p>How to clear the callback after it has been fired?</p>
  
  <pre><code>$.rails.allowAction = function(element) {
  
    var message = element.data('confirm'),
    answer = false, callback;
    if (!message) { return true; }
  
    if ($.rails.fire(element, 'confirm')) {
      myCustomConfirmBox(message, function() {
       callback = $.rails.fire(element,
         'confirm:complete', [answer]);
       if(callback) {
         var oldAllowAction = $.rails.allowAction;
         $.rails.allowAction = function() { return true; };
         element.trigger('click');
         $.rails.allowAction = oldAllowAction;
       }
      });
    }
    return false;
  }
  
  function myCustomConfirmBox(message, callback) {
      $('#dialog-confirm').modal('show');
      $('#dialog-confirm button.primary').click(function(){
          callback();
          $('#dialog-confirm').modal('hide');
      });
  }
  </code></pre>
  
  <p>edit:
  Since I'm using the same base modal over and over again for any delete action, the callbacks queue up. So when a delete action has been cancelled before, it will still be triggered on another delete instance of a different object, since the callback is still valid. Bottom line: How to clear the callback queue?  </p>