Ticket #6280 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

Unable to prevent form submit

Reported by: guest Owned by: alex
Priority: high Milestone: 1.1
Component: Dijit Version: 1.1b1
Severity: blocker Keywords: form submit
Cc: bill

Description

I am unable to prevent the form submit process on IE7 only. It works fine on ie6, firefox. Problem seen with 1.1b3 and 1.1rc1

 <form dojoType="dijit.form.Form" id="myForm" onSubmit="return false;">

       <input id="idSearch" type="text" dojotype="dijit.form.TextBox" name="line" style="width: 12em" trim="true"  />
          <button dojoType="dijit.form.Button"   type="submit">
	No submit 
	</button>                    
    </form>

Change History

Changed 16 months ago by doughays

  • owner set to doughays
  • version set to 1.1b1
  • milestone set to 1.1

regression in [12067]

Changed 16 months ago by doughays

  • cc bill added
  • owner changed from doughays to alex
  • priority changed from normal to high

Sorry, about the prior post but I was only looking at dijit changes before.
If I take the current trunk and roll back only dojo/_base/html.js to [12893] then it works. Probably the ability of dojo.attr to handle value types of function is broken.

Changed 16 months ago by doughays

  • severity changed from major to blocker

Run dijit/demos/form.html on any browser
Press OK. Press Cancel to not submit the form, but the submit proceeds.

Changed 16 months ago by doughays

  • keywords ie7 removed
  • summary changed from Unable to prevent form submit ie7 only to Unable to prevent form submit

dojo.attr was changed in revision [12899] to use connect for function values. But this doesn't work for functions like onsubmit and onreset that have to return a boolean that tell the browser whether to proceed or not. There may be other functions that work the same as well (onclick?).

Changed 16 months ago by bill

See also #6292, a dup of this.

Changed 16 months ago by alex

doughays: using dojo.connect() for those events allows us to handle cancelation in a uniform way. The preferred syntax for the above is:

 <form dojoType="dijit.form.Form" id="myForm" onSubmit="dojo.stopEvent(arguments[0]);">

Which will call dojo.stopEvent() on the passed event object on all browsers which I've tested on. I'll update the docs on dojo.attr()'s behavior and also add a test cage for this use-case, but fundamentally it's not a bug.

Regards

Changed 16 months ago by alex

  • status changed from new to closed
  • resolution set to fixed

(In [13181]) update docs and default behavior for dijit.Form and dojo.attr to make it crystal clear that unified Dojo event handling is in play when using event handlers specified by dojo.attr() and that browser-specific hacks may no longer work as expected. Fixes #6280. !strict

Changed 16 months ago by bill

(In [13191]) Patch from Doug to make onsubmit="return false;" work on dijit.Form (in addition to dojo.stopEvent()), like on native <form> elements. Fixes #6299, refs #6280, #6292.

Note: See TracTickets for help on using tickets.