title: Close modal window JQuery?
body: <p>I have page with products. 
  When adding a product to the shopping cart a modal window is fired up for confirmation - this can take up to 2 seconds.</p>
  
  <p>I  want to show another modal window just before the confirmation modal to show "loading..."</p>
  
  <p>my problem is that I don't know how to close the "loading..." modal when the 'confirmation' modal is appear.</p>
  
  <p>This the code which fired up the confirmation modal:</p>
  
  <pre><code> $(document).ready(function () {
          var $dialog = $('&lt;div style="background-color:red"&gt;&lt;/div&gt;')
          .html('&lt;h1&gt;loading...&lt;/h1&gt;')
          .dialog({
              autoOpen: false,
              title: 'loading...'
          });
          $('.AddToCartButton').click(function () {
              $dialog.dialog('open');
          });        
  
      });
  </code></pre>
  
  <p>On the 'confirmation' modal I am trying to close the the 'loading..." modal with this code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $('#AddToCartButton').dialog('close');    
  &lt;/script&gt;
  </code></pre>
  
  <p>Thanks.</p>