Is there a way that I can call $(selector).bind('click', handler) or $(selector).on('click', handler) several times so that the handler only binds once?
I currently have several AJAX handlers with callbacks with different successes, each of which re-displays a different set of elements on the page. Ideally, I would like to reorganize the "repeat events" subroutine into one function, rather than the usual for everyone.
The only way I can do this now is to explicitly untie it, for example:
$(selector).off('click'); $(selector).on('click', handler);
Looking for a way to do something like this automatically.
javascript jquery javascript-events idempotent
wrschneider
source share