title: jQuery dialog box with dynamic table delete record button not working
body: <p>I have been writing a script that opens a dialog box and within the dialog box there is a dynamic table with data pulled out of one of my databases. I have put delete buttons next to all the records so that staff can remove unnecessary records.<br>
  I was trying to use an click function that triggers an Ajax request which then deletes the record from the database instantly.<br>
  But what happens is that when I click the delete button it closes the dialog box and doesn't delete anything at all. I have copied my code bellow if that is of any help.</p>
  
  <p>all help is greatly appreciated :)</p>
  
  <pre><code> //including all jquery library
  
  &lt;script&gt;
      $(function() {
          $( "#dialog" ).dialog({
              autoOpen: false,
                      buttons: {
  
                  "Add to Log": function() {
                  $.ajax({
                      type: 'POST',
                      url: "check_add.php",
                      data: $('#checkup').serialize(),
  
                      success: function(data) {
  
                               if(data == 0){//Failure 
                                      alert('Data was NOT saved in db!');
                                           }
                                   }
                  });
                    $( this ).dialog( "close" );
  
  
                  },
                  Exit: function() {
                      $( this ).dialog( "close" );
                  }
              }
  
          });
  
              $( "#opener" ).click(function() {
              $( "#dialog" ).dialog( "open" );
              return false;
          });
  
  
          $( "#reminder" ).dialog({
              width: 471,
              autoOpen: false,
                      buttons: {
  
                  Exit: function() {
                      $( this ).dialog( "close" );
                  }
              }
          });
  
              $( "#remind" ).click(function() {
              $( "#reminder" ).dialog( "open" );
              return false;
          });
  
  
          $(".Delete").click(function() // here the delete function
          {
              var $this = $(this);
              var rowid = $this.attr('name');
              $.ajax({
              type: "POST",
              url: 'check_del.php',
              data: {
              'id': rowid
                  },
              success: function(data) {
  
          if(data == 1){//Success 
               alert('Sucess');
            }
          if(data == 0){//Failure 
               alert('Data was NOT saved in db!');
            }
              }
   });
          }); 
  
  
      });
      &lt;/script&gt;
  
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;button id="opener"&gt;Add Damage&lt;/button&gt;
  &lt;button id="remind"&gt;Reminder&lt;/button&gt;
  
  &lt;div id="dialog" style="font-size:small;"&gt;
  &lt;form name="checkup" method="post" id="checkup"&gt; 
      &lt;table&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;strong&gt;Cases:&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;input name="cases" type=text  placeholder="Cases ID" maxlength="7" style="width:129px;"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Comments:&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt; &lt;textarea name="comment" placeholder="Comments Box"&gt;&lt;/textarea&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;?php
  </code></pre>
  
  <p>//database connection stuff</p>
  
  <pre><code>$sql="select * from $tbl_name";
  $result=mysql_query($sql);
  
  ?&gt;
  
  
  &lt;div id="reminder" style="font-size:small;"&gt;
  &lt;form name="remind" method="post" id="remind"&gt; 
      &lt;table bordercolor="#000000" border="1" style="border:thin;"&gt;
      &lt;th&gt;Class&lt;/th&gt;
      &lt;th&gt;Cases&lt;/th&gt;
      &lt;th&gt;First Name&lt;/th&gt;
      &lt;th&gt;Last Name&lt;/th&gt;
      &lt;th&gt;Model&lt;/th&gt;
      &lt;th&gt;Comments&lt;/th&gt;
      &lt;th&gt;   &lt;/th&gt;
  
  &lt;?
      while($rows=mysql_fetch_array($result)){
  $cases=strtoupper($rows['cases']);
  ?&gt;
  
      &lt;tr&gt;
      &lt;td&gt;&lt;? echo $rows['hg']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;? echo $cases;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;? echo $rows['firstname']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;? echo $rows['surname']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;? echo $rows['model']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;? echo $rows['comments']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;button  name="&lt;?php echo $rows['id']; ?&gt;"  class="Delete"&gt;Delete&lt;/button&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/table&gt; 
  &lt;?
  }
  ?&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>