Is it possible to re-enable selection after using e.preventdefault() in the user-select event?

Is it possible to re-enable selection after using e.preventdefault() in the user-select event?

gfctamgfctam Posts: 2Questions: 1Answers: 0

Is it possible to re-enable selection after using e.preventdefault() or return false in the user-select event?
I try to find an answer but no end so I ask for help. Please don't blame me if I am stupid.

I disable selection on the table like below.

  $maintenanceTable.on('user-select', function (e, dt, type, cell, originalEvent) {
        return false;
  });

Then, I would like to re-enable the selection.
Here is what I hv done but it doesn't work.

  $maintenanceTable.off('user-select', function (e, dt, type, cell, originalEvent) {
        return true;
  });

I google it there is a bind() and unbind() can solve these similar issues but not for datatable. Therefore, is there any solution in here?

Thanks a lot:)

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @gfctam ,

    You could do something like this, disable the on just before exiting, which means the next click would work.

    Cheers,

    Colin

  • gfctamgfctam Posts: 2Questions: 1Answers: 0

    Thanks @colin
    That works like a charm

This discussion has been closed.