Ticket #7061 (closed bug: fixed)
Delegated submit handler can interfere with default action of click event on IE
| Reported by: | Tgr | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | event | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Submit delegation being simulated with click delegation in IE can have unexpected results. Consider the following code:
$('html').delegate('form', 'submit', function() {
$(this).find(':submit').attr('disabled', true);
});
which is a common way to prevent accidental double postings; delegation is used to make sure this will execute after validation etc. submit handlers.
This will work fine in most browsers, but submit does not bubble in IE, and jQuery simulates it via the click event. When you set the submit button to disabled inside a click handler, the form will not submit, because the default action for clicking a disabled button is to do nothing.
I'm not sure if this counts as a bug, or just a perk of the cross-browserization of event delegation, but maybe you could use click handlers to detect submit delegation, and when detected, add a new submit handler to the form (and then remove it as needed) so that the event handler is actually run as a submit handler, not a click handler?
On a partially related note, please add jQuery.support.submitBubbles/changeBubbles to the http://api.jquery.com/jQuery.support/ doc page.
Change History
comment:2 Changed 3 years ago by snover
- Keywords needsreview added
- Priority changed from undecided to low
- Milestone 1.4.3 deleted
Review as per comment:1 by dmethvin.
comment:4 Changed 3 years ago by anonymous
I vote for fixing this. If you are attempting to simulate the submit event in IE, then you shouldn't introduce an unexpected behavior by your chosen solution (a click). If it is supposed to simulate the submit event, then it should submit even when the button is disabled. Otherwise, the simulation seems half-baked.
comment:5 Changed 3 years ago by snover
There’s a 3rd party pull request open for this bug.
comment:6 Changed 2 years ago by cracell
This issue effects disabling the submit button functionality for IE7 and IE8 under jQuery 1.4.4 still. Specifically causing issues with the Rails UJS driver https://github.com/rails/jquery-ujs/issues/#issue/30
comment:8 Changed 2 years ago by dmethvin
- Keywords needsreview removed
- Status changed from new to open
comment:10 Changed 22 months ago by dmethvin
Related to #6262, and equally hard to fix.
comment:11 Changed 22 months ago by dmethvin
#6262 is a duplicate of this ticket.
comment:12 Changed 22 months ago by dmethvin
#8748 is a duplicate of this ticket.
comment:13 Changed 21 months ago by Dave Methvin
- Status changed from open to closed
- Resolution set to fixed
Fix #7061. Lazy-attach to the genuine submit event for delegation.
Avoids the problems that arise when we try to trigger submit behavior at clicky-time.
Changeset: a4cdbf09ee97471ec041d83ceb8f3feb9825b2a1
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I've updated the docs to expose submitBubbles and changeBubbles. The remaining open issue is to determine whether this quirk of the delegate/live submit handler should be fixed or simply documented.