Search code examples
jquerydomdatatablesdraw

How can I keep my draw function while using dom positioning in datatables?


I am loading thumbnails into my datatable via draw.dt function:

  var table = $('.datatable').DataTable({
     //... code
  });

  $('.datatable').on( 'draw.dt', function() {
    loadThumbnails();
  });

This works well, but I try now to display my pagination into the header, so I am adding:

   var table = $('.datatable').DataTable({
       "dom": '<"col-sm-6"<"dataTables_length"l>><"col-sm-6"<"dataTables_filter"p>><"clear">',
  });

But now my thumbnails are not loaded anymore.


Solution

  • You miss t for table, try with

    dom: '<"col-sm-6"<"dataTables_length"l>><"col-sm-6"<"dataTables_filter"p>>"clear">t',
    

    If you not use t the table itself is omitted.