Skip to main content

Bug Tracker

Side navigation

#6337 closed bug (fixed)

Opened March 23, 2010 03:24PM UTC

Closed September 24, 2010 10:03PM UTC

Button click within form causes submit event even though return false is there

Reported by: margieroginski Owned by: dmethvin
Priority: undecided Milestone: 1.4.3
Component: event Version: 1.4.2
Keywords: submit event return false Cc:
Blocked by: Blocking:

I have a small test case below where I create a button inside a form and set its onclick hander to my js function, show_input(), followed by a "return false", like this:

Immediately following that is a one line script that clicks the button.

	    <button id="testbutton1" onclick="show_input(); return false;">
	    <script type="text/javascript">

In jquery 1.3.2, when the .click() occurs, it calls show_input() and no submit event occurs aftwards, due to the return false. But in in Jquery 1.4.2, it calls show_input() and then the submit event fires (it does a GET), as if the return false is not there.

If I manually click the button, I do not see the submit event, so this seems to be somehow related to the click being inline.

Here is the exact html that can be used to replicate it.

    <script src="/site_media/js/jquery-1.3.2.js" type="text/javascript"></script>
    <script type="text/javascript">
      function show_input() {
        console.log("hello, world");

  <div id="container">
      <div class="taskform_row_description form-row">
	    <button id="testbutton1" onclick="show_input(); return false;">
	    <script type="text/javascript">

This seems to me to be a bug since it is very incompatible with previous behavior...



Attachments (0)
Change History (4)

Changed June 15, 2010 01:01AM UTC by dmethvin comment:1

component: unfiledevent

Changed July 28, 2010 02:39AM UTC by dmethvin comment:2

owner: → dmethvin

It looks like the problem is in jQuery.event.trigger; the code to run inline scripts sets event.result to false but does not stopPropagation or preventDefault. I've taken the ticket and will put together a patch.

Changed August 26, 2010 01:45AM UTC by dmethvin comment:3

Changed September 24, 2010 10:03PM UTC by john comment:4

priority: → undecided
resolution: → fixed
status: newclosed


We only need to call preventDefault in this case.