Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#11284 closed enhancement (fixed)

[patch] [cla] dojox.form.manager._Mixin to pass !this.watch as priorityChange when setting values

Reported by: ben hockey Owned by: Eugene Lazutkin
Priority: high Milestone: 1.5
Component: DojoX Form Version: 1.5.0b2
Keywords: Cc:
Blocked By: Blocking:

Description

dijit.form._FormValueWidget allows passing an extra optional parameter (priorityChange) when setting form widget values which will prevent onChange from firing.

	_setValueAttr: function(/*anything*/ newValue, /*Boolean, optional*/ priorityChange){
		// summary:
		//		Hook so attr('value', value) works.
		// description:
		//		Sets the value of the widget.
		//		If the value has changed, then fire onChange event, unless priorityChange
		//		is specified as null (or false?)
		this.value = newValue;
		this._handleOnChange(newValue, priorityChange);
	},

since the onChange is now fired via a setTimeout, the priorityChange parameter is really the most effective way to prevent/ignore onChange.

without the setTimeout it was possible to have the observer ignore the onChange by setting this.watch = false; then in the next line of code set widget values in the form via the form manager and then set this.watch = true; again. however, with the setTimeout firing the onChange now, it has become difficult to prevent/ignore onChange.

i considered 2 ways that the form manager could pass in the priorityChange parameter.

  • change formWidgetValue (and other functions which call it) to take a priorityChange parameter that is passed along to the widget's setter when setting values of widgets.
  • pass in !this.watch as the priorityChange parameter when setting form widget values.

i like the 2nd option since it doesn't change any function signatures and uses the value of this.watch to (indirectly) prevent the observer from being fired. i will attach a patch for this option but would be interested in discussing other options.

Attachments (1)

11284.patch (820 bytes) - added by ben hockey 9 years ago.
use !this.watch as priorityChange

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by ben hockey

Attachment: 11284.patch added

use !this.watch as priorityChange

comment:1 Changed 9 years ago by Eugene Lazutkin

Milestone: tbd1.5
Status: newassigned

comment:2 Changed 9 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

(In [22384]) form.manager: priorityChange support, thx neonstalwart!, !strict, fixes #11284.

comment:3 Changed 8 years ago by Douglas Hays

This change is causing the failure in #14985. "this.watch" (changed later to this.watching) is undefined inside the anonymous functions.

Note: See TracTickets for help on using tickets.