This example demonstrates the restoreRow() function. This is useful if your AJAX update failed and the values (in table) should be restored to the original. NOTE: every other request will fail.
$.tableEditor.lib.restoreRow(o.row,o.original); is used within the update function to restore the row
| ID | First Name | Last Name | Phone | City | |
|---|---|---|---|---|---|
| XXX | |||||
| Brice | Burgess | (800)768-5283 | Milwaukee | b@b.com | |
| Christian | Bach | (800)768-6288 | Chicago | c@c.com | |
| Abe | Lincoln | (800)223-2331 | Washington D.C. | l@l.com | |
| Sam Lightning | Hopkings | (800)728-1221 | Houston | s@s.com | |
| Rudyard | Kipling | (512)121-1280 | London | r@r.com |
<script type="text/javascript">
$().ready(function() {
$("#editableTable").tableSorter({
sortClassAsc: 'headerSortUp', // class name for ascending sorting action to header
sortClassDesc: 'headerSortDown', // class name for descending sorting action to header
headerClass: 'header', // class name for headers (th's)
disableHeader: 'ID' // DISABLE Sorting on ID
}).tableEditor({
EDIT_HTML: 'edit',
SAVE_HTML: 'save',
EVENT_LINK_SELECTOR: 'button.eventLink',
FUNC_UPDATE: 'updateTable'
});
document.counter = 0;
});
function updateTable(o) {
document.counter++;
if ((document.counter%2) == 0) {
// restore row
alert('Update failed. Row restore.');
$.tableEditor.lib.restoreRow(o.row,o.original);
}
else
alert('Update Success');
return true;
}
</script>