initComplete for all datatables
initComplete for all datatables
![itajackass](https://secure.gravatar.com/avatar/8734d72a9b7f5f8631f74ac3731cbdee/?default=https%3A%2F%2Fvanillicon.com%2F8734d72a9b7f5f8631f74ac3731cbdee_200.png&rating=g&size=120)
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