Getting Datatables Object when its initialized
Getting Datatables Object when its initialized

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.