Bug Tracker

Ticket #10844 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

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


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..


  $('body').delegate('#myForm', 'submit', function()

This works:

    <form id="myForm">
      <input type="submit" value="Submit" />

This doesn't work:

    <form id="myForm">
      <input name="id" type="hidden" value="foo" />
      <input type="submit" value="Submit" />

The same issue when using .on() function.

Change History

comment:1 Changed 4 years ago by dmethvin

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

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.


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

  • 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 4 years ago by dmethvin

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

comment:5 Changed 4 years 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

Note: See TracTickets for help on using tickets.