2

I have brought datatable's default click event on every first column by disabling responsive display's type //type: 'none',. Now, for some targeted action, I want to disable those click event from the first columns.

So, I have written this:

$('td:first-child').off('click');

But, click event hasn't been stopped. How to do this? Here is my demo.

2
  • preventDefault .................. Commented Sep 1, 2019 at 20:02
  • I wish comments could be downvoted. Commented Sep 1, 2019 at 20:05

1 Answer 1

2

This plugin does not seem to attach individual click handlers. Rather there is a global handler on tbody and all the logic is within. So the whole thing becomes a double-edged sword. You can achieve what you want using this:

$('tbody').off('click.dtr mousedown.dtr mouseup.dtr');

However, you should keep in mind a few things:

  1. There might be some undesired side-effect to this. I do not know how exactly this large handler works so in order to figure this out you should check the code out (which is where I found the correct events and their namespaces): download the non-minified code with the Response extension, find the _detailsInit() function and read through it - that should be a good enough start.
  2. There are probably some keyboard handlers as well, and depending on what you are doing you might want to take care of those too.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.