据我所知,您可以为所有数据表设置默认值:
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"num-html-desc": function (a, b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
但我想为fnInitComplete设置一个默认函数,该函数将与/不在其他地方覆盖此函数一起使用 - 因此是默认值。我怎么能做到这一点?
答案 0 :(得分:1)
您可以添加fnInitComplete
默认值:
$.extend($.fn.dataTable.defaults, {
"fnInitComplete": function (oSettings, json) { doSomething(); }
});
为了防止在设置数据表时覆盖它,您可以这样做:
$('#myTable').dataTable({
//lots of other properties here
"fnInitComplete": function (oSettings, json) {
$.fn.dataTable.defaults.fnInitComplete(oSettings, json);
doSomethingElse();
}
});