Undefined 'dt' parameter when .on('select') is triggered
Undefined 'dt' parameter when .on('select') is triggered
When I call the 'on' select method on a DataTable instance, I receive 'undefined' when logging 'dt' to the console. Here's the code as defined:
$('#table').DataTable().on('select.dt', function(e, dt, type, indexes) {
console.log(dt);
...do something...
}
From the Select documentation examples, I see that any reference to the DataTable instance from within the event, actually refers to a pre-defined instance of DataTable (table
), rather than the 'dt' parameter in the function definition.
Is the 'dt' parameter actually supposed to be a DataTables API instance or have I misunderstood its meaning?
Answers
Using the
dt
parameter in this example works:https://jsfiddle.net/hwn9dsev/
Maybe you have an incorrect selector in the function causing the
undefined
output. Please update or provide a test case replicating your issue so we can help.Kevin