Skip to content

Handler receives null event object for remote form submit on IE #222

@symve

Description

@symve

On IE8 at least, the following does not work. (Using rails.js of November 07, 2011, and jQuery 1.6.2)

  1. Load the HTML below into IE8
  2. Open the developer tools (F12) and switch to the log console on the scripts subtab
  3. Press the Submit button

Here's the console output that is generated. Note the submit event is received twice: first with event == null and second with a valid event object.

LOG: submit form; event = null
ERR: 'null' is null or not an object
LOG: submit form, event = [object Object]

Removing the rails.js include or the data-remote attribute on the form makes it all work again. As expected the handler is only called once, and the event object actually exists.

<!DOCTYPE html>
<html>
  <head>
    <title>Rails.js Bug Demo</title>
  </head>

  <body>
    <form action="/submit/path" data-remote="true">
      <input type="submit">
    </form>

    <script src="./jquery.min.js"></script>
    <script src="./rails.js"></script>
    <script>
      $('form').submit(function (event) {
        console.log('submit form, event = ' + event);
        event.preventDefault();   // Will cause error because event == null.
        return false;   // To prevent moving away from this page.
      });
    </script>
  </body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions