Jquery UI dialog will not close on first try, takes several clicks
<p>I am using Jquery-UI dialog library but when I try to close it, there seems to have been several identical dialogs beneath it that had spawned, and it takes several clicks to close them all. Sometimes the buttons in the dialog are unresponsive.</p>

<pre><code>        if (!($(clicked).attr("type")) || ($(clicked).attr("type") == "text")){
            newDialog("What Would You Like To Type Here ?",
            "test");
            return false;
        }
function newDialog(mytitle, mycontent){
   var $dialog = $('&lt;div id="myunique"&gt;&lt;/div&gt;')
        .html(mycontent)
        .dialog({
            autoOpen: false,
            modal: false,           
            title: mytitle,
            width: 500
        });
    $dialog.dialog('open'); 

    //return false;
}
</code></pre>
