jQuery Event Handling
Cloning elements and Binding and Rebinding events
Use .clone(true) to copy event handlers as well. This article describes in more detail and also talks about rebinding and unbinding events manually when doing DOM manipulation other than cloning.
It is important to note this breaking change - which will probably break some of our projects:
Beware! As of jQuery 1.4.2, binding the same handler to the same element multiple times will cause it to execute more than once. This differs from previous versions of jQuery as well as the DOM 2 Events spec (which normally ignores duplicate event handlers).
Leave a Comment