Capture event after sorting on datatable with jquery
I've an issue with a datable (http://www.datatables开发者_StackOverflow社区.net), jQuery and Firefox.
I've a jQuery datatable (id="equipmentList"
) with a button above:
<html:button styleId="deleteButton" property="delete" value="<%= buttonDelete %>" disabled="disabled" />
When i'm sorting a column on the datatable, i want to disable a button (the button deleteButton
), so I wrote this code :
$('#equipmentList th').click( function() {
hideButtonEditAndDelete();
});
function hideButtonEditAndDelete() {
$("#modifyButton").attr("disabled", "disabled");
$( "#deleteButton" ).attr("disabled", "disabled");
//fix for firefox
if($.browser.mozilla){
$("#modifyButton").addClass('ui-state-disabled');
$("#deleteButton").addClass('ui-state-disabled');
}}
Everything goes well until the sort is ending because, after, my button is enabled by jQuery; or something else. so I'm looking for capture event at the end of sorting order to disable my button
There is a callback that is made every time that the table is redrawn and can be accessed on the fnDrawCallback:
$('#someTable').dataTable({
"fnInitComplete": function() {
// after table is intialised do something here
},
"fnDrawCallback": function() {
// after table is redrawndo something here
console.log("redrawn");
},
"bDestroy": true,
"bAutoWidth": false,
"bPaginate": false,
"sScrollY": "242px",
"bLengthChange": false,
"bInfo": false,
"bFilter": false,
"aaSorting": [[2, 'asc']],
"aoColumns": [
{ "sSortDataType": "dom-checkbox", "sWidth": "3%" },
{ "bSortable": true, "sWidth": "8%" },
{ "bSortable": true, "sWidth": "10%" },
{ "bSortable": true, "sWidth": "15%" },
{ "bSortable": true, "sWidth": "8%" },
{ "bSortable": true, "sWidth": "9%" },
{ "bSortable": true, "sWidth": "6%" },
{ "bSortable": false, "sWidth": "2%" },
{ "bSortable": false, "sWidth": "7%" },
{ "bSortable": false, "sWidth": "13%" },
{ "bSortable": false, "sWidth": "2%" },
{ "bSortable": false, "sWidth": "7%" },
{ "bSortable": false, "sWidth": "10%" }
]
});
More info on callbacks here:
http://datatables.net/usage/callbacks
精彩评论