initComplete for all datatables
initComplete for all datatables
itajackass
Posts: 162Questions: 48Answers: 3
Is there a way to add a unique script to add a initComplete event FOR ALL TABLES FOR ALL PAGES?
I'd like to color the bFilter when is compiled.
This work perfectly in my "common-script-for-all-pages.js" on change event.
$("body").on("change", ".dataTables_filter input", function(e) {
if ( $(this).val() != "" ) {
$(this).addClass("label-warning");
} else {
$(this).removeClass("label-warning");
}
});
But if refresh page using F5, page reload, bfilter get the value inserted before (this is correct) but "label-warning" class is gone
This discussion has been closed.
Answers
Yes, use the
init
event which bubbles up the document so you can do:This is what many of the extensions do.
Allan