Do I need to wait to initialize DataTables in document.ready when using server-side processing?

Do I need to wait to initialize DataTables in document.ready when using server-side processing?

dnortondnorton Posts: 6Questions: 1Answers: 0

All examples show the DataTables initialization occurring in document.ready, like this:

$(document).ready(function() {
$('#example').DataTable();
} );

When using server-side processing, the HTML rendered is just an empty table. Can I run the initialization in a script rendered at the bottom of the page without waiting for the ready function to be called?

Replies

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    As long as $('#example').DataTable() executes when the id=example element is in the document then it will work. If you place the script after the table element, that should be just fine.

    Allan

This discussion has been closed.