jQuery ui dialog wont work second time
<p>Hi I have an button and onClick i pop up a jQuery ui Dialog box with some form elements in it. the first time i click everything works perfectly but second time i click the box appears but my form elements are gone and its just an empty dialog box. Any ideas whats going wrong? The code im using is:</p>

<pre><code>var $dialog = $('&lt;div id="saveDialog"&gt;&lt;/div&gt;')
    .html('Please choose the folder you wish to save the file in:')
    .dialog(
    {
        autoOpen: false,
        modal: true,
        buttons: {Ok: function()
            {
                $( this ).dialog( "close" );
            }},
        show: "blind",
        hide: "explode",
        resizable: true,
        minWidth: 500,
        maxWidth: 800,
        height: 400,
        open: function()
        {
            var phpArray = &lt;?php echo json_encode($directories); ?&gt;;
            $.each(phpArray, function (i, elem) 
            {
                   $('#saveDialog').append('&lt;br&gt; &lt;img src="/app/webroot/css/jqueryFileTree/images/directory.png"/&gt;&lt;a id="'+elem+'"&gt;'+elem+'&lt;/a&gt;');

            });
         }

$dialog.dialog('open');
    return false;
</code></pre>

<p>Thanks in advance!</p>
