Reputation: 622
Hi all i work with datatables,
I want to add class to each table row element in each page.
But for some case is adding only for first page new class, but for other no, how i can to fix this?
My code:
$(document).ready(function () {
var table = $('.table-style').DataTable();
$('.dropdown').addClass("test")
table.draw();
});
Upvotes: 0
Views: 563
Reputation: 161
You need to add class after the datatable is drawn. This event will be called on pagination or when the page loads. So you can execute your js code or add class on each page. Here is a sample code.
$(document).ready( function() {
$('.custom-style').dataTable( {
"fnDrawCallback": function( oSettings ) {
$('.dropout').addClass("test");
}
} );
} );
For more info see this https://legacy.datatables.net/ref#fnDrawCallback
Upvotes: 1