title: Close all open dialog boxes? (JQuery)
body: <p>How can I close all opened <code>dialog</code> boxes in <code>jQuery</code>?
  The situation is next: I have a simple page without dialogs. It has some buttons what open it owns dialogs.</p>
  
  <p>When I click on a button I need to close all opened dialogs.</p>
  
  <p>Here is the HTML:</p>
  
  <pre><code>&lt;div id="buttons"&gt;
      &lt;a href="#" id="btn_1"&gt;Button 1&lt;/a&gt;
      &lt;a href="#" id="btn_2"&gt;Button 2&lt;/a&gt;
      &lt;a href="#" id="btn_3"&gt;Button 3&lt;/a&gt;
  &lt;/div&gt;
  &lt;div id="dialog_1" class="dialogbox"&gt;...&lt;/div&gt;
  &lt;div id="dialog_2" class="dialogbox"&gt;...&lt;/div&gt;
  &lt;div id="dialog_3" class="dialogbox"&gt;...&lt;/div&gt;
  </code></pre>
  
  <p>And here is the jQuery:</p>
  
  <pre><code>$(function() {
      $('#buttons').find('a').click(function() {
          // close all dialogs
          $('.dialogbox').dialog("close");
  
          // find out clicked id and open dialog
          var nr = this.id.split("_")[1];
          $('#dialog_'+nr).dialog();
      });
  });
  </code></pre>
  
  <p>The Chrome say: <code>Uncaught Error: cannot call methods on dialog prior initialization; attempted to call method 'close'</code>.</p>
  
  <p>I was tried to check <code>$('.dialogbox').dialog('isOpen')</code>, but same result.</p>
  
  <p>How can I close all dialogs?</p>