title: jQuery UI dialog close doesn't clear dialog
body: <p>Using <a href="http://en.wikipedia.org/wiki/JQuery_UI" rel="nofollow noreferrer">jQuery UI</a>, I have a tabs plugin and within tab 1 gets loaded a page that contains a table and in each row is a link to a dialog.</p>
  
  <p>Everything works correctly, save the following:</p>
  
  <p>In the dialog is an option to delete the row from which the current dialog was opened from. After confirming, and deleting the row, the tab is refreshed and the new table is shown with the relevant row deleted.</p>
  
  <p>Now, the problem is that after closing the dialog where I did the deletion (either though the JavaScript function that did the deleting, or manually via the close button on the dialog), the dialog retains the data from the deleted row.</p>
  
  <p>For example,</p>
  
  <p>There are three rows listed;</p>
  
  <p>Open dialog from row 2;</p>
  
  <p>Delete;</p>
  
  <p>Dialog closed from the JavaScript function, tab refreshes, now two rows;</p>
  
  <p>The dialog open link in the second row (which used to be row 3) has the same dialog id as the one just opened;</p>
  
  <p>Click open dialog link in row 2;</p>
  
  <p>Dialog displays same as before - for old row 2, instead of current row 2;</p>
  
  <p>Close dialog;</p>
  
  <p>Click open dialog link in row 2;</p>
  
  <p>Displays correctly - data from current row 2;</p>
  
  <p>I don't know if that made any sense... Here's a picture of what happens:</p>
  
  <p><img src="https://i.stack.imgur.com/T9AX6.png" alt="Enter image description here"></p>
  
  <p>So, the row below the row that gets deleted inherits the dialog id, and when clicked shows the old dialog. If closed, then re-opened, it shows the proper content in the dialog.</p>
  
  <p>I'm using <code>dialog("close")</code> currently and have tried <code>dialog("destroy")</code>, but that totally kills it, and the row below doesn't open anything...</p>
  
  <p>How can I fix this problem?</p>
  
  <hr>
  
  <p>Dialog instantiation code:</p>
  
  <pre><code>&lt;script&gt;
  &lt;?php
  $ee=1;
  foreach($bugs-&gt;result() as $rr){
      echo "jQuery(\"#dialog_$ee\").dialog({autoOpen:false,width:850,height:550});\n";
      $ee++;
  }
  ?&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Then open the dialog:</p>
  
  <pre><code>jQuery("#dialog_&lt;?=$i?&gt;").dialog("open");
  </code></pre>