Reputation: 1372
Is it possible to say to JQuery, hey! unbind any event handlers before adding this one, without making an explicit call to unbind?.
Something like
$("jq selector").click(function() { ...}, true);
Where true means I want to unbind all click handlers set to the element. I've came across this on various occasions and on some had strange behaviours due not unbinding event handlers first.
Thanks.
Upvotes: 4
Views: 1043
Reputation: 1372
There are many ways to do this but I believe the correct would be:
$(selector).unbind("click").click(function() { ... });
I give the credit of the answer to Pointy, who replyed in a comment, but since he didn't add it as an answer I share it to the community.
Upvotes: 0