Friday, December 7, 2012

How to Know If The DataTables is Running

That's just a tip for you guys who are working with the DataTables plug-in. If you need to know if the DataTables JS code is properly running, you can just pass a parameter to it to have a message box as result.

That's is really simples:
  1. $(document).ready( function() {
  2. $('#example').dataTable( {
  3. "fnInitComplete": function(oSettings, json) {
  4. alert( 'DataTables has finished its initialisation.' );
  5. }
  6. } );
  7. } )

The fnInitComplete function is called when the Datatables finishes its initialization, so if that doesn't show up, you will be able to know that the plug-in haven't started.

I know that's quite simple, but this small code has helped me to find out an another big problem.

No comments:

Post a Comment