form does not work on 2nd submission
Hi There,
I have the following code that launches modal forms from within tabs. For each of the rows in the table below, I can launch the modal, edit the data in the form and save the changes. However, If I attempt to edit any of the rows a second time, everything submits, but the new data is ignored. It is almost as if the previous data for that row is cached.
Can anyone please shed any light on what I am doing wrong?
- <script type="text/javascript">
$(function() {
//var formData = '';
var $loading = $('<img src="images/widgets/loading.gif" alt="loading" class="loading">');
$('#admins td a.edit').each(function() {
var $dialog = $('<div></div>')
.append($loading.clone());
var $link = $(this).one('click', function() {
var current_aduid = $link.attr('id');
$dialog
.load($link.attr('href') + '#content')
.dialog({
title: $link.attr('title'),
width: 600,
height: 430,
modal: true,
buttons: {
"Save": function () {
var formData = $("#editadmin_" + current_aduid + "").serializeArray();
//$("#editadmin_" + current_aduid + "").submit();
$(this).dialog("close");
$.ajax({ type: "POST", url: "administrators/ssbin/do_edit_administrator.php?aduid=" + current_aduid +"", cache: false, data: formData, "success": function() {
$('#tabs').tabs('load', 0)}});
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$link.click(function() {
//current_aduid = $(this).attr('id');
$dialog.dialog('open');
return false;
});
return false;
});
});
});
- </script>
- <table id="admins" class="tablesorter ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header">
<th class="header">Last Name / First Name </th>
<th class="header">Email </th>
<th class="header">Last Login </th>
<th class="header">View / Edit </th>
</tr>
</thead>
<tbody>
<tr>
<td> Small, Jared</td>
<td> t@uvw </td>
<td> 2008-06-26 15:28:51 </td>
<td> <a aria-disabled="false" role="button" href="administrators/edit_administrator_il.php?ssmode=IL&aduid=1" id="1" class="edit ui-button " title="View/Edit ">Edit</a> </td>
</tr><tr>
<td> Minh, Danny</td>
<td> x@xyz </td>
<td> 2010-07-29 14:23:02 </td>
<td> <a aria-disabled="false" role="button" href="administrators/edit_administrator_il.php?ssmode=IL&aduid=22" id="22" class="edit ui-button " title="Edit ">Edit</a> </td>
</tr>
</tbody>
</table>