我遇到了数据(http://www.datatables.net),jQuery和Firefox的问题。
我有一个jQuery数据表(id="equipmentList"
),上面有一个按钮:
<html:button styleId="deleteButton" property="delete" value="<%= buttonDelete %>" disabled="disabled" />
当我在数据表上对列进行排序时,我想禁用一个按钮(按钮deleteButton
),所以我写了这段代码:
$('#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');
}}
一切顺利,直到排序结束,因为之后,我的按钮由jQuery启用;或者是其他东西。所以我在排序顺序结束时寻找捕获事件来禁用我的按钮
答案 0 :(得分:7)
每次重绘表时都会进行回调,并且可以在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%" }
]
});
有关回调的更多信息: