on Draw running multiple times

on Draw running multiple times

dataBdataB Posts: 23Questions: 5Answers: 1
edited May 2017 in DataTables 1.10

I've noticed that the Draw event is sometimes triggered multiple times on a page load. On a site where I have multiple pages with various DT setups the following code will trigger 1-3 times (varying by page). Each page calls the same DT and jQuery files.

table.on( 'draw', function () {
    alert( 'Table redrawn' );
} );

Any ideas why? I've used DT for some time and never noticed this before.

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Have you tried it with deferRender : true?

  • dataBdataB Posts: 23Questions: 5Answers: 1

    I do have deferRender on. I tried it with deferRender true and false and get the same result.

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    this fired only once on live.datatables.net

    $(document).ready( function () {
      $('#example').on( 'draw.dt', function () {
        console.log( 'Redraw occurred at: '+new Date().getTime() );
    } );
      var table = $('#example').DataTable();
    } );
    

    can we see your javascript to see if something else is going on?

This discussion has been closed.