The scenario I have on my hands is that I have a PHP generated table with multiple rows fetched from a database displayed on a page. Each row has a unique ID. I would like to be able to add the functionality to edit each row.
So far I am using the dialog from this website to create the dialog pop up which works with a static button (exactly how it works in the Animated example).
Simply put, I want to be able to click anywhere in the row to trigger the dialog, and pass the unique ID using jQuery to a PHP file to generate the content for the dialog.
So far here is my attempt at the content to display within the dialog.
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "fade",
duration: 100
},
hide: {
effect: "fade",
duration: 100
}
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
var id = <somehow fetch the ID through a form or class within a span or somehow!>;
var dataString = 'id=' + id;
$.ajax({
type: "POST",
url: "edit.php",
data: dataString,
success: function(response) {
$('.ui-dialog-content').html(response);
}
});
return false;
});
});
</script>
To simply sum it up my problem, I can't get row to trigger a dialog even when I add <tr id="opener">...</tr>
it still doesn't open and the other problem passing a unique ID (named $db_id
in the PHP script that generates each row into the AJAX script triggered by opening the dialog.
Thanks in advance!
Edit: It would probably be worth noting that I know extremely little about javascript/jQuery so please explain anything relating to it in the most simplest terms with given examples is possible! :)