Can initComplete be 'listened' from one instance of datatable object?

Can initComplete be 'listened' from one instance of datatable object?

teojicdteojicd Posts: 6Questions: 6Answers: 0

I understand that if we have already initialized a datatable on one HTML table element, then we can access the instance of that object with the following line of code:

var table = $("#searchProdTable").DataTable();

Normally initComplete is used in this manner:

$('#example').dataTable( {
  "initComplete": function(settings, json) {
    alert( 'DataTables has finished its initialisation.' );
  }
} );

What I want to know if it is possible to 'listen' to the initComplete event of an already initialized datatable. I was thinking if such a syntax is possible:

var table = $("#searchProdTable").DataTable();
table.initComplete (){
  console.log("table has finished initialization"); 
}

Or that is not possible at all. Whatever initComplete callback handler you want, you have to write it straight away when creating the datatable.

Thanks!

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @teojicd ,

    You can use init, this is likely to do what you want. See the example on the bottom of that page,

    Cheers,

    Colin

This discussion has been closed.