#2977 closed bug (fixed)
wrap() methods lose events
Reported by: | rodnaph | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | core | Version: | 1.4a1 |
Keywords: | clone wrap events | Cc: | |
Blocked by: | Blocking: |
Description
When using the wrap() method, events I have added to the element are lost (because wrap() uses clone() which doesn't preserve events). Shouldn't jQuery actually preserve events on elements? (or atleast provide the option to preserve them without having to rely on a plugin?)
Example:
$( 'img' ).wrap(
$( '<a></a>' )
.click( doSomething )
);
Change History (6)
comment:1 Changed 15 years ago by
comment:2 Changed 14 years ago by
Actually, I seem to have an even worse problem.
var jq = $(elem); var div = $('<div></div>'); jq.wrap(div); div.click(function () { alert('click!'); });
I click the DIV - nothing happens. So it seems that whenever I use wrap() on a JQuery object, I can't bind any events to it whatsoever. Tested in Firefox 3.0.1 on Windows XP.
comment:3 Changed 14 years ago by
Keywords: | clone wrap events added |
---|
comment:4 Changed 14 years ago by
Please, fix this issue. It's just about adding true as parameter of the clone function called from wrapAll function.
comment:5 Changed 13 years ago by
Milestone: | 1.3 → 1.4 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Version: | 1.2.5 → 1.4a1 |
This bug is also in 1.2.6.