Bug Tracker

Modify

Ticket #3115 (closed bug: wontfix)

Opened 6 years ago

Last modified 19 months ago

document.formName.submit() is not caught by .submit() binding

Reported by: jstayton Owned by:
Priority: minor Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc:
Blocking: Blocked by:

Description

When a form is submitted via document.formName.submit(), it is not caught by the .submit() function bound to the form.

Example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
      <title>jQuery .submit() example</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <script type="text/javascript" src="jquery-1.2.6.min.js"></script>
      <script type="text/javascript">
         $(document).ready(function() {
            $('form[name="testForm"]').submit(function() {
              alert('Submitted!');

              return false;
            });
         });
      </script>
   </head>
   <body>
      <form name="testForm" action="submitExample.html" method="post">
        <input type="text" name="textField" value="Press submit" />
        <input type="submit" name="submitButton" value="Submit" />
        <input type="button" name="submitButton" value="Submit with document.testForm.submit()" onclick="document.testForm.submit();" />
      </form>
   </body>
</html>

The 'Submit' button is properly caught (and an alert displays), but 'Submit with document.testForm.submit()' is not.

Change History

comment:1 Changed 6 years ago by flesler

  • Status changed from new to closed
  • Resolution set to wontfix
  • Component changed from core to event

I think this is how it works natively. Calling form.submit() will simply skip the handlers.

Use $(form).submit() instead.

comment:2 Changed 19 months ago by dmethvin

#12575 is a duplicate of this ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.