Skip to main content

Bug Tracker

Side navigation

#11649 closed bug (fixed)

Opened April 25, 2012 07:56PM UTC

Closed May 18, 2012 08:37PM UTC

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/

Attachments (0)
Change History (5)

Changed April 25, 2012 08:05PM UTC by MoonScript <jason@moonscript.com> comment:1

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.

Changed April 28, 2012 05:32PM UTC by dmethvin comment:2

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.

Changed May 09, 2012 10:39PM UTC by anonymous comment:3

Proposed fix has been created here:

https://github.com/jquery/jquery/pull/771

Changed May 10, 2012 03:42AM UTC by anonymous comment:4

Alternative fix proposed here:

https://github.com/jquery/jquery/pull/772

Changed May 18, 2012 08:37PM UTC by Jason Moon comment:5

resolution: → fixed
status: openclosed

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

Changeset: e93f2a89e277d3fffbc15b4ef82ebc3ac6a840f5