title: Working with variables outside of jquery UI dialog
body: <p>I have a .each that loops through table rows and compares information already entered to what the user is currently attempting to add. I have conditionals in the loop that look for duplicate entries across each of the s in the row. Depending on how many match, there's a yes/no decision for the user to make. If the user chooses yes, the current row needs to be removed. I am using jQuery UI and am having problems getting the dialog box to know what row to remove, or having the .each loop know what was selected in the dialog. 
  The .each loop looks like this:</p>
  
  <pre><code>$('#tblSelectedList &gt; tbody &gt; tr').each(function() {
  </code></pre>
  
  <p>Here's the code for the dialog (within in the for loop):</p>
  
  <pre><code>                $('&lt;div&gt;&lt;/div&gt;').appendTo('body')
                  .html('&lt;div&gt;&lt;h6&gt;Delete duplicate?&lt;/h6&gt;&lt;/div&gt;')
                  .dialog({
                      modal: true,
                      title: 'Delete message',
                      zIndex: 10000,
                      autoOpen: true,
                      width: 'auto',
                      resizable: false,
                      buttons: {
                          Yes: function () {
                              removeThis = 1;
                              blnAdd = 1;
                              $(this).dialog("close");
                          },
                          No: function () {
                              blnAdd = 0;
                              $(this).dialog("close");
                          }
                      },
                      close: function (event, ui) {
                          $(this).remove();
                      }
                  });
  </code></pre>
  
  <p>and the method I am using to remove rows:</p>
  
  <pre><code>var id = $(this).attr('id').substring(7,$(this).attr('id').length);
  $('#tblSelectedList #row-'+id).remove();
  </code></pre>
  
  <p>Everything works independently, but I can't get the dialog and its containing .each loop to know what the other is doing.</p>