Undefined 'dt' parameter when .on('select') is triggered

Undefined 'dt' parameter when .on('select') is triggered

berryintlonlineberryintlonline Posts: 2Questions: 1Answers: 0
edited February 2019 in Free community support

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

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,948
    edited February 2019

    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

This discussion has been closed.