title: Jquery UI modal dialogs
body: <p>I have a problem with Jquery UI modal dialogs. I have modal dialog (dialogA), which can create another modal dialog (dialogB). After the second creation and closure of the dialogB the overlay of dialogA disappear.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head&gt;&lt;link type="text/css" rel="Stylesheet" href="ui-lightness/jquery-ui-1.8.custom.css" /&gt;
      &lt;script type="text/javascript" src="jquery-1.4.2.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="jquery-ui-1.8.custom.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function createDialog(dialogId) {
     $('#' + dialogId).dialog({
      autoOpen: true,
      modal: true,
      buttons: {
       'close': function() {
        $(this).dialog('close');
       },
       'create': function() {
        var newDialogId = dialogId + '1';
        $('body').append('&lt;div id="' + newDialogId + '"&gt;' + newDialogId + '&lt;/div&gt;');
        createDialog(newDialogId);
       }
      },
      close: function() {
       $(this).dialog('destroy');
       $(this).remove();
      }
     });
    }
  
    $(document).ready(function() {
     $('#button1').click(function() {
      var dialogId = 'dialog';
      $('body').append('&lt;div id="' + dialogId + '"&gt;' + dialogId + '&lt;/div&gt;');
      createDialog(dialogId);
     });   
    });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;button id="button1"&gt;Create dialog&lt;/button&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><a href="http://jsbin.com/otama" rel="nofollow noreferrer">http://jsbin.com/otama</a></p>
  
  <p>Steps to reproduce:<br>
  1. create a dialog (dialog) by clicking on the button<br>
  2. create another dialog (dialogA) by clicking on the "create" button inside first dialog<br>
  3. close dialogA<br>
  4. repeat steps 2-3<br>
  5. overlay of the first dialog has been disappeared  </p>
  
  <p>Thanks</p>