Ticket #10844 (closed bug: fixed)
.delegate() on submit doesn't work when form contains input with name "id"
| Reported by: | tarmaq | Owned by: | dmethvin |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7.1 |
| Component: | event | Version: | 1.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
If I create submit handler via .delegate() or .on() function, the selector is the id of the form, form contains input named="id", handler is't called after submitting..
Example:
$('body').delegate('#myForm', 'submit', function() { alert('works!'); });
This works:
<body> <form id="myForm"> <input type="submit" value="Submit" /> </form> </body>
This doesn't work:
<body> <form id="myForm"> <input name="id" type="hidden" value="foo" /> <input type="submit" value="Submit" /> </form> </body>
The same issue when using .on() function.
Change History
comment:1 Changed 19 months ago by dmethvin
- Status changed from new to closed
- Resolution set to cantfix
comment:2 Changed 19 months ago by tarmaq
But this was working with jQuery v1.6.4, after upgrading to v1.7 it's broken.
comment:3 Changed 19 months ago by dmethvin
- Priority changed from undecided to blocker
- Resolution cantfix deleted
- Status changed from closed to reopened
- Component changed from unfiled to event
- Milestone changed from None to 1.7.1
You're right, this is a regression because it used to go through Sizzle. So I'll put the same fix into the delegate testing.
comment:4 Changed 19 months ago by dmethvin
- Owner set to dmethvin
- Status changed from reopened to assigned
comment:5 Changed 19 months ago by Dave Methvin
- Status changed from assigned to closed
- Resolution set to fixed
Fix #10844. Harden quickIs() against form-aliasing of the id property.
Changeset: 8cb065addc13a8042523b6db4bfd1d80a33c9a46
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

There is no easy way to fix this and it's not specific to jQuery. Bowsers alias the form input names on the form element. You can use this tool to avoid such conflicts.
http://kangax.github.com/domlint/