You must kill the previous event handler:
<script> $('body').off('click','.todo', do_stuff); $('body').on('click', '.todo', do_stuff); </script>
Including the function of the event handler in the off()
function, only this handler will be deleted, and not all the others that are called by the same elements / events. Also, avoid anonymous functions while doing this.
Currently, it is also proposed to abandon unbind()
and kill()
. on() / off()
should meet all your event processing needs, including future real-time bindings and pending results.
source share