如何在 table 抽奖时触发 initComplete?
How can I fire initComplete on table draw?
当我加载我的页面时,我的警报“初始化完成”被触发。
var table = $('.datatable').DataTable({
...
"initComplete": function(settings, json) {
alert("init complete");
}
});
但是当我稍后想在一个函数中重绘我的数据表时,没有触发警报“init complete”:
function filter(value) {
table
.search( '' )
.columns().search( '' )
.columns(3)
.search(value, true, false)
.draw();
}
$('.filter').on( 'click', 'a', function (e) {
filter($(this).attr('href'));
});
Init complete 仅触发一次:when your table has fully been initialised, data loaded and drawn, particularly when using an ajax data source
。这就是为什么当您重绘 table.
时它不会 运行 的原因
所以我认为你需要类似 drawCallback 的东西:It can be useful to take an action on every draw event of the table
注意:如果您使用 drawCallback,则不需要 initComplete,当 table 完全加载时,它会触发 drawCallback
当我加载我的页面时,我的警报“初始化完成”被触发。
var table = $('.datatable').DataTable({
...
"initComplete": function(settings, json) {
alert("init complete");
}
});
但是当我稍后想在一个函数中重绘我的数据表时,没有触发警报“init complete”:
function filter(value) {
table
.search( '' )
.columns().search( '' )
.columns(3)
.search(value, true, false)
.draw();
}
$('.filter').on( 'click', 'a', function (e) {
filter($(this).attr('href'));
});
Init complete 仅触发一次:when your table has fully been initialised, data loaded and drawn, particularly when using an ajax data source
。这就是为什么当您重绘 table.
所以我认为你需要类似 drawCallback 的东西:It can be useful to take an action on every draw event of the table
注意:如果您使用 drawCallback,则不需要 initComplete,当 table 完全加载时,它会触发 drawCallback