Side navigation
#10844 closed bug (fixed)
Opened November 21, 2011 03:04PM UTC
Closed November 21, 2011 04:33PM UTC
Last modified March 08, 2012 09:03PM UTC
.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: | ||
Blocked by: | Blocking: |
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:
#!text/html <body> <form id="myForm"> <input type="submit" value="Submit" /> </form> </body>
This doesn't work:
#!text/html <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.
Attachments (0)
Change History (5)
Changed November 21, 2011 03:21PM UTC by comment:1
resolution: | → cantfix |
---|---|
status: | new → closed |
Changed November 21, 2011 03:41PM UTC by comment:2
But this was working with jQuery v1.6.4, after upgrading to v1.7 it's broken.
Changed November 21, 2011 03:55PM UTC by comment:3
component: | unfiled → event |
---|---|
milestone: | None → 1.7.1 |
priority: | undecided → blocker |
resolution: | cantfix |
status: | closed → reopened |
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.
Changed November 21, 2011 03:55PM UTC by comment:4
owner: | → dmethvin |
---|---|
status: | reopened → assigned |
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/