Side navigation
#2977 closed bug (fixed)
Opened June 04, 2008 02:24PM UTC
Closed December 08, 2009 08:41PM UTC
Last modified November 16, 2013 03:20PM UTC
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 )
);
Attachments (0)
Change History (6)
Changed June 05, 2008 04:33PM UTC by comment:1
Changed August 12, 2008 11:03AM UTC by comment:2
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.
Changed January 18, 2009 12:05AM UTC by comment:3
keywords: | → clone wrap events |
---|
Changed March 31, 2009 06:45PM UTC by comment:4
Please, fix this issue. It's just about adding true as parameter of the clone function called from wrapAll function.
Changed December 08, 2009 08:41PM UTC by comment:5
milestone: | 1.3 → 1.4 |
---|---|
resolution: | → fixed |
status: | new → closed |
version: | 1.2.5 → 1.4a1 |
This bug is also in 1.2.6.