Bug Tracker

Opened 7 years ago

Closed 7 years ago

#11649 closed bug (fixed)

delegated form submit event handler does not fire after being removed and re-added in IE7/8

Reported by: f1sherman Owned by:
Priority: low Milestone: 1.next
Component: event Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

This works properly in IE9, newest stable versions of Chrome, Firefox, Safari. Does not work in IE7/8. Confirmed in jQuery 1.7.1 and 1.7.2.

See the following fiddle: http://jsfiddle.net/f1sherman/zUxUT/26/

Change History (5)

comment:1 Changed 7 years ago by MoonScript <jason@…>

This is happening because the form content is being retrieved via the .html() function, which includes the jQuery submit-delegation artifact on the form tag: _submit_attached="true". When that HTML string is then repopulated into the DOM, the submit event on that new form does not bubble, because it already contains the _submit_attached attribute, so jQuery skips it.

I think any jQuery-introduced markup should be stripped out when retrieved via .html(), which would solve this issue.

comment:2 Changed 7 years ago by dmethvin

Component: unfiledevent
Milestone: None1.next
Priority: undecidedlow
Status: newopen

@Moonscript, thanks for the analysis!

Your proposed solution would fix the problem, but the price would be pretty high. jQuery would have to walk the entire subtree to find any added properties or attributes. We already have to do this for .clone() (in cloneFixAttributes) but doing it on any DOM detach seems like a real mess. This issue is aggravated because oldIE treats properties and attributes interchangeably. If it would just clone attributes and not custom properties I don't think we'd have a problem.

comment:3 Changed 7 years ago by anonymous

Proposed fix has been created here: https://github.com/jquery/jquery/pull/771

comment:4 Changed 7 years ago by anonymous

Alternative fix proposed here: https://github.com/jquery/jquery/pull/772

comment:5 Changed 7 years ago by Jason Moon

Resolution: fixed
Status: openclosed

Fix #11649. Preserve oldIE submit flag when cloning, closes gh-772.

Changeset: e93f2a89e277d3fffbc15b4ef82ebc3ac6a840f5

Note: See TracTickets for help on using tickets.