Bug: Cannot combine select, deselect event handlers

Bug: Cannot combine select, deselect event handlers

dtdevdtdev Posts: 9Questions: 4Answers: 0
edited July 2016 in Free community support

For the select extension, the "select" and "deselect" events can be defined separately, as shown in this example. However, using the standard jQuery event combination method (i.e., each event separated by a space) does not work:

e.g.,

table.DataTable().on("select deselect", function (e, dt, type, indexes) {
        console.log("Not firing for both events...");
    }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin
    Answer ✓

    Hi, You need to add the .dt namespace:

    .on("select.dt deselect.dt",  ...
    

    With a single event it will automatically add the namespace for you - its a bug that it doesn't for multiple events - sorry.

    Allan

  • dtdevdtdev Posts: 9Questions: 4Answers: 0

    Awesome, thanks! That fixed the problem.

This discussion has been closed.