Add classes to elements (bs5)

Add classes to elements (bs5)

dtriangledtriangle Posts: 5Questions: 2Answers: 0

Using jQuery, I have added the bootstrap class 'pagination-sm' after the table, to make it smaller.

$('ul.pagination').addClass('pagination-sm');

however, it is getting removed again when ever the table changes (e.g. gets filtered). Must be simple way around this?

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,950Questions: 87Answers: 416
    Answer ✓

    use the "draw" event to add the class. So that it gets added whenever the table is drawn or redrawn.

    https://datatables.net/reference/event/draw

  • dtriangledtriangle Posts: 5Questions: 2Answers: 0

    Thanks again rf1234, that has done the trick. I've used this code:

    table.on( 'draw', function () {
        $('ul.pagination').addClass('pagination-sm');
        $('div.dt-buttons').addClass('btn-group-sm');
    } );
    
Sign In or Register to comment.