Turn click events on and off
Turn click events on and off

I want to disable all click events from my datatable.
I can do this with
var table = $('#example').DataTable();
$('#example').off('click');
But I can not enable the eventhandler later on.
This does not work.
$('#example').on('click');
Same with .bind() and .unbind()
What am I doing wrong?
This discussion has been closed.
Answers
Hi @taich ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Here is a test case.
http://live.datatables.net/wufiwute/1/
Once you click on any row, all data of the row you clicked is logged to console. After that the eventhandler is turned off(). And you cant turn it on any more.
No more click events will happen.
Thanks for the test case - it helps to clear up what events you are referring to. The problem is you can't just use
$('#example').on();
. When you use jQuery .off() it does allow for an empty set of parameters with this comment in the docs:The docs for jQuery .on() specify that one or more events must be passed to the API. Otherwise jQuery won't know what events to turn on.
Kevin