Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12575 closed bug (duplicate)

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

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

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

comment:1 Changed 11 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

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

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

Version 0, edited 11 years ago by Rick Waldron (next)

comment:2 Changed 11 years ago by dmethvin

Resolution: notabug
Status: closedreopened

comment:3 Changed 11 years ago by dmethvin

Resolution: duplicate
Status: reopenedclosed

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.