Bug Tracker

Ticket #12575 (closed bug: duplicate)

Opened 2 years ago

Last modified 2 years ago

native form submit event doesn't trigger $.submit event

Reported by: after.fallout@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocking: Blocked by:

Description

I am not sure if this is a bug in the documentation or in Core, but I cannot find anything that suggests this is by design.

jsfiddle:  http://jsfiddle.net/8KNc7/5/

basically:

document.getElementById('theform').submit();

doesn't trigger

$('theform').submit();

See:  http://forum.jquery.com/topic/why-doesn-t-submitting-a-form-via-the-submit-method-on-the-form-element-invoke-submit-handlers

If this is on purpose, why doesn't  http://api.jquery.com/submit/ say anything that suggests this is true?

Change History

comment:1 Changed 2 years ago by rwaldron

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

Why would it? Those are two different APIs...

There is no documentation because we expect that users at least understand that if you're using jQuery, then you use jQuery. Right?

Last edited 2 years ago by rwaldron (previous) (diff)

comment:2 Changed 2 years ago by dmethvin

  • Status changed from closed to reopened
  • Resolution notabug deleted

comment:3 Changed 2 years ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to duplicate

Duplicate of #3115.
Just for bookeeping, this is a dup.

We can't fire jQuery events because the native DOM doesn't call its handlers when you call the DOM form.submit() method. That's the way it works. There is no event we receive that would allow us to run the attached handlers.

You can run the handlers without submitting again via .triggerHandler("submit") if you can find a place to put it.

It's not mentioned in the docs because if you use jQuery it works fine via either .trigger("submit") or the .submit() shorthand.

 http://jsfiddle.net/dmethvin/4AVSv/

If you use the native DOM methods underneath us, we can't always control what they do. Not sure how many places we can put information like that.

Note: See TracTickets for help on using tickets.