Base class for widgets corresponding to native HTML elements such as <checkbox> or <button>,
which can be children of a <form> node or a `dijit.form.Form` widget.
description
Represents a single HTML element.
All these widgets should have these attributes just like native HTML input elements.
You can set them during widget construction or afterwards, via `dijit._Widget.attr`.
They also share some common methods.
dijit.form._FormWidget.name
tags: const
type
String
summary
Name used when submitting form; same as "name" attribute or plain HTML elements
dijit.form._FormWidget.alt
type
String
summary
Corresponds to the native HTML <input> element's attribute.
dijit.form._FormWidget.value
type
String
summary
Corresponds to the native HTML <input> element's attribute.
dijit.form._FormWidget.type
type
String
summary
Corresponds to the native HTML <input> element's attribute.
dijit.form._FormWidget.tabIndex
type
Integer
summary
Order fields are traversed when user hits the tab key
dijit.form._FormWidget.disabled
type
Boolean
summary
Should this widget respond to user input?
In markup, this is specified as "disabled='disabled'", or just "disabled".
dijit.form._FormWidget.intermediateChanges
type
Boolean
summary
Fires onChange for each value change or only on demand
dojo.declare("dijit.form._FormWidget", [dijit._Widget, dijit._Templated, dijit._CssStateMixin], { // summary: // Base class for widgets corresponding to native HTML elements such as or
if(value){ // reset these, because after the domNode is disabled, we can no longer receive // mouse related events, see #4200 this._set("hovering", false); this._set("active", false);
// clear tab stop(s) on this widget's focusable node(s) (ComboBox has two focusable nodes) var attachPointNames = "tabIndex" in this.attributeMap ? this.attributeMap.tabIndex : "focusNode"; dojo.forEach(dojo.isArray(attachPointNames) ? attachPointNames : [attachPointNames], function(attachPointName){ var node = this[attachPointName]; // complex code because tabIndex=-1 on a
doesn't work on FF if(dojo.isWebKit || dijit.hasDefaultTabStop(node)){ // see #11064 about webkit bug node.setAttribute('tabIndex', "-1"); }else{ node.removeAttribute('tabIndex'); } }, this); }else{ if(this.tabIndex != ""){ this.focusNode.setAttribute('tabIndex', this.tabIndex); } }
// summary: // Callback when this widget's value is changed. // tags: // callback
summary
Callback when this widget's value is changed.
tags:
dijit.form._FormWidget._onChangeActive
tags: private
type
Boolean
summary
Indicates that changes to the value should call onChange() callback.
This is false during widget initialization, to avoid calling onChange()
when the initial value is set.
dijit.form._FormWidget._handleOnChange
type
Function
parameters:
newValue: (typeof anything)
the new value
priorityChange: (typeof Boolean)
For a slider, for example, dragging the slider is priorityChange==false,
but on mouse up, it's priorityChange==true. If intermediateChanges==false,
onChange is only called form priorityChange=true events.
if(this._lastValueReported == undefined && (priorityChange === null || !this._onChangeActive)){ // this block executes not for a change, but during initialization, // and is used to store away the original value (or for ToggleButton, the original checked state) this._resetValue = this._lastValueReported = newValue; } this._pendingOnChange = this._pendingOnChange || (typeof newValue != typeof this._lastValueReported) || (this.compare(newValue, this._lastValueReported) != 0); if((this.intermediateChanges || priorityChange || priorityChange === undefined) && this._pendingOnChange){ this._lastValueReported = newValue; this._pendingOnChange = false; if(this._onChangeActive){ if(this._onChangeHandle){ clearTimeout(this._onChangeHandle); } // setTimout allows hidden value processing to run and // also the onChange handler can safely adjust focus, etc this._onChangeHandle = setTimeout(dojo.hitch(this, function(){ this._onChangeHandle = null; this.onChange(newValue); }), 0); // try to collapse multiple onChange's fired faster than can be processed } }
summary
Called when the value of the widget is set. Calls onChange() if appropriate
dojo.declare("dijit.form._FormWidget", [dijit._Widget, dijit._Templated, dijit._CssStateMixin], { // summary: // Base class for widgets corresponding to native HTML elements such as or