I have an event handler set up using plain javascript like this:
myElement.addEventListener('drop', handleDrop, false);
Then, inside handle drop I try to do this:
var myContainer = $(this.parentNode);
myContainer.after(myContainer.clone(true, true));
However, it appears that the event is not being carried over to the cloned element. Is this happening because I am not binding the event with jQuery also?
I tried to test this by binding the event with jQuery instead, but that doesn’t support the dataTransfer object so it broke other code.
One solution is to write your own wrapper for addEventListener that remembers the listeners which were added, so they can be “replayed”:
Then:
If you have no religious convictions preventing you from overwriting the original method on the Element object:
and then: