title: Modal won't close on ajax success
body: <p>I'm loading in the content of a modal with ajax. I have a button that submits the modal form and is suppose to close the modal when it's done processing the ajax submit so it can update a table at the bottom of the page. It's not closing the modal after I update the table and call <code>$('modal-container').modal('hide');</code></p>
  
  <p>This modal contains a table that has pagination on it. In the 'loaded.bs.modal' event I turn all the links that have the <code>modal-pagination-link</code> class into an ajax link. The pagination library I'm using only allows the url and parameters of the link to be passed in which is why I do this link transformation after they're loaded. When you click on one of these links it updates the table. In order to prevent the modal itself from closing after you click the link I call <code>$(this).removeData('bs.modal');</code>. What I've found is this <code>$(this).removeData('bs.modal');</code> is what is preventing any of the <code>$('#modal-container').modal('hide');</code>'s from working.</p>
  
  <p>How do I prevent the modal from closing when a link is clicked on in the modal and still allow <code>.modal('hide')</code> to still work? What can I call instead of <code>$(this).removeData('bs.modal')</code>?</p>
  
  <pre><code>$(function () {
  // Initialize modal dialog
  // attach modal-container bootstrap attributes to links with .modal-link class.
  // when a link is clicked with these attributes, bootstrap will display the href content in a modal dialog.
  $('body').on('click', '.modal-link', function (e) {
      e.preventDefault();
      $(this).attr('data-target', '#modal-container');
      $(this).attr('data-toggle', 'modal');
      $('#modal-container').draggable();
      var updateTarget = $(this).attr('data-ajax-update');
      $('modal-update-target').attr('value', updateTarget);
  });
  // Attach listener to .modal-close-btn's so that when the button is pressed the modal dialog disappears
  $('body').on('click', '.modal-close-btn', function () {
      $('#modal-container').modal('hide');
  });
  //clear modal cache, so that new content can be loaded
  $('body').on('hidden.bs.modal', '.modal', function () {
      $(this).removeData('bs.modal');
      $('modal-update-target').removeAttr("value");
  });
  
  $('#modal-container').on('click', '.modal-pagination-link', function (e) {
      var updateTarget = $(this).attr('data-ajax-update');
      $('modal-update-target').attr('value', updateTarget);
  });
  
  $('#modal-container').on('loaded.bs.modal', function () {
      $(this).removeData('bs.modal');
      $('modal-update-target').removeAttr("value");
      var pagcontainers = $(this).find('#modal-pagination');
      var hrefs = $(pagcontainers).find('a').addClass('modal-pagination-link')
                                              .attr('data-ajax', 'true')
                                              .attr('data-ajax-mode', 'replace')
                                              .attr('data-toggle', 'modal')
                                              .attr('data-target', '#modal-container')
                                              ;
  
  });
  
  $('#modal-container').on('submit', '#asset-modal-frm', function (e) {
      e.preventDefault();
      if (confirm("Are you sure?")) {
          var data = $(this).serializeArray();
          $.ajax({
              url: '/licenses/allocate',
              type: 'POST',
              data: data,
  
              success: function (data) {
                  for (var i = 0; i &lt; data.length ; i++) {
                      $('#allocatedLicenses tr:last').after(
                      $("&lt;tr&gt;").append($("&lt;td&gt;").text(data[i].name))
                                      .append($("&lt;td&gt;").text(data[i].manufacturerItem.serialNumber)));
                  }
                  $('#modal-container').modal('hide');
              }
          })
      }
  });
  });
  </code></pre>
  
  <p>my html:</p>
  
  <pre><code>    &lt;div id="modal-container" class="modal fade" tabindex="-1" role="dialog"&gt;
          &lt;input id="modal-update-target" type="hidden"/&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content center-block" style="display: table;"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>