Getting Datatables Object when its initialized

Getting Datatables Object when its initialized

pbxManpbxMan Posts: 2Questions: 2Answers: 0

I have the following code:

var table = $('#example').DataTable(jsonAjaxCall);
 
table.on( 'select', function ( e, dt, type, indexes ) {
    table[ type ]( indexes ).nodes().to$().addClass( 'custom-selected' );
} );

As my DataTable is loaded with ajax the object table on the second line may be null. How can I solve this?

This discussion has been closed.