Modal dialog with edit/delete for table rows

Modal dialog with edit/delete for table rows

Here's my goal: have a table of data with edit/delete buttons. The edit buttons open a modal dialog with the form pre-populated with the details for the appropriate row. I have had trouble getting the ajax to work to actually fill out the form on the fly, so I'm just opening an edit page inside the modal and passing the id. It works great...for the first edit button. Nothing at all happens on subsequent edit buttons. I'm at a loss. I'm no javascript or jquery expert, but have googled away and haven't found anything to handle my situation (or that I could successfully adapt). I'm pretty sure it involves .each and/or .sibilngs, but I'm not sure how to implement. Here's what I have:


  1. <link type="text/css" href="js/css/start/jquery-ui-1.8.9.custom.css" rel="stylesheet" />   
    <script type="text/javascript" src="js/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="js/js/jquery-ui-1.8.9.custom.min.js"></script>
    <script type="text/javascript">



  2. $(function(){
  3.     $('#edit_number').dialog({    autoOpen: false,width: 400,height: 500,    modal:true, open: function() {
            var editqs = 'process.php?action=edit_num_form&id=' + $(this).data('num_id') + '&rep_id=<?php echo $rep_id ?>';
            $("#edit_number").load(editqs);
            }
        });



  4.     $('#edit_number_link').click(function(){
              var id = $(this).closest('tr').attr('data-id');
               $("#edit_number").data('num_id', id).dialog('open');
            return false;
        });

    });





  5. </script>

And my HTML amounts to (in PHP, leaving out data retrieval and other columns):
  1.   echo "<tr data-id=".$id."><td>" . $name . "</td>";
      echo "<td><a href='#' title='Edit' id='edit_number_link'><img src='edit.png' alt='Edit' border='0'></a></td>";
So ideally, I can get retrieve my data from each edit button to load the form in a real modal (not an external page), but at a minimum, need the additional instances to work.

Any help would be appreciated. Thanks!