Skip to main content

Bug Tracker

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 dmethvin comment:1

resolution: → cantfix
status: newclosed

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/

Changed November 21, 2011 03:41PM UTC by tarmaq 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 dmethvin comment:3

component: unfiledevent
milestone: None1.7.1
priority: undecidedblocker
resolution: cantfix
status: closedreopened

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 dmethvin comment:4

owner: → dmethvin
status: reopenedassigned

Changed November 21, 2011 04:33PM UTC by Dave Methvin comment:5

resolution: → fixed
status: assignedclosed

Fix #10844. Harden quickIs() against form-aliasing of the id property.

Changeset: 8cb065addc13a8042523b6db4bfd1d80a33c9a46