Bug Tracker

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#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:
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:

  <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 (5)

comment:1 Changed 4 years ago by dmethvin

  • Resolution set to cantfix
  • Status changed from new to closed

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/

comment:2 Changed 4 years ago by tarmaq

But this was working with jQuery v1.6.4, after upgrading to v1.7 it's broken.

comment:3 Changed 4 years ago by dmethvin

  • Component changed from unfiled to event
  • Milestone changed from None to 1.7.1
  • Priority changed from undecided to blocker
  • Resolution cantfix deleted
  • Status changed from closed to 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.

comment:4 Changed 4 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from reopened to assigned

comment:5 Changed 4 years ago by Dave Methvin

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Changeset: 8cb065addc13a8042523b6db4bfd1d80a33c9a46

Note: See TracTickets for help on using tickets.