Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#9968 closed defect (fixed)

Form: "reset()" method does not call "onReset" event

Reported by: nervo Owned by: Douglas Hays
Priority: high Milestone: 1.5
Component: Dijit - Form Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

In dijit.form.Form, it seems that calling programmatically the reset method does not call the onReset() event.

I see in dijit.form._FormMixin :

reset: function(){
	dojo.forEach(this.getDescendants(), function(widget){
		if(widget.reset){
			widget.reset();
		}
	});
},

Maybe dijit.form._FormMixin or dijit.form.Form should override this method to call a this.onReset()

Attachments (1)

9968.patch (3.7 KB) - added by Douglas Hays 10 years ago.
call onReset() when reset() is called so user can stop reset

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by bill

Component: GeneralDijit
Description: modified (diff)
Milestone: tbd1.5
Owner: anonymous deleted
Summary: In dijit.form.Form "reset()" method does not call "onReset" eventForm: "reset()" method does not call "onReset" event

I see that the documentation for onReset does mention reset() calling onReset(), as you talked about:

onReset: function(/*Event?*/ e){
	// summary:
	//		Callback when user resets the form. This method is intended
	//		to be over-ridden. When the `reset` method is called
	//		programmatically, the return value from `onReset` is used
	//		to compute whether or not resetting should proceed
	// tags:
	//		callback
	return true; // Boolean
},

But, it doesn't seem like programatically calling reset() *should* call onReset(), because onReset() is meant for stopping users from resetting a form in the same way that onSubmit() is meant to stop users from sending a form. (But we don't want to stop developers from resetting a form.) Maybe it's just the documentation for onReset() that's incorrect?

Anyway, it's worth some thought.

comment:2 Changed 10 years ago by Douglas Hays

Owner: set to Douglas Hays

It seems that all supported browsers fire cancellable onreset events for native FORM.reset() yet do not fire onsubmit events for native FORM.submit().

Changed 10 years ago by Douglas Hays

Attachment: 9968.patch added

call onReset() when reset() is called so user can stop reset

comment:3 Changed 10 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [21017]) Fixes #9968. Change reset() to call stoppable onReset first and add automated tests.

comment:4 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.