A set of widgets indexed by id. Deprecated, will be removed in 2.0.
See the dijit/WidgetSet reference documentation for more information.
Create a small list of widgets:
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ var ws = new WidgetSet(); ws.add(registry.byId("one")); ws.add(registry.byId("two")); // destroy both: ws.forEach(function(w){ w.destroy(); }); });
Add a widget to this list. If a duplicate ID is detected, a error is thrown.
Parameter | Type | Description |
---|---|---|
widget | dijit/_WidgetBase | Any dijit/_WidgetBase subclass. |
Reduce this widgetset to a new WidgetSet of a particular declaredClass
Parameter | Type | Description |
---|---|---|
cls | String | The Class to scan for. Full dot-notated string. |
Find all dijit.TitlePane
s in a page:
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ registry.byClass("dijit.TitlePane").forEach(function(tp){ tp.close(); }); });
Find a widget in this list by it's id.
Parameter | Type | Description |
---|---|---|
id | String |
Test if an id is in a particular WidgetSet
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ var ws = new WidgetSet(); ws.add(registry.byId("bar")); var t = ws.byId("bar") // returns a widget var x = ws.byId("foo"); // returns undefined });
A synthetic clone of array.every
acting explicitly on this WidgetSet
Parameter | Type | Description |
---|---|---|
func | Function | A callback function run for every widget in this list. Exits loop when the first false return is encountered. |
thisObj | Object |
Optional Optional scope parameter to use for the callback |
Filter down this WidgetSet to a smaller new WidgetSet
Works the same as array.filter
and NodeList.filter
Parameter | Type | Description |
---|---|---|
filter | Function | Callback function to test truthiness. Is passed the widget reference and the pseudo-index in the object. |
thisObj | Object |
Optional Option scope to use for the filter function. |
Arbitrary: select the odd widgets in this list
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ registry.filter(function(w, i){ return i % 2 == 0; }).forEach(function(w){ /* odd ones */ }); });
Call specified function for each widget in this set.
Parameter | Type | Description |
---|---|---|
func | Function | A callback function to run for each item. Is passed the widget, the index
in the iteration, and the full hash, similar to |
thisObj | Object |
Optional An optional scope parameter |
Returns self, in order to allow for further chaining.
Using the default dijit.registry
instance:
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ registry.forEach(function(widget){ console.log(widget.declaredClass); }); });
Create a new Array from this WidgetSet, following the same rules as array.map
Parameter | Type | Description |
---|---|---|
func | Function | |
thisObj | Object |
Optional
|
A new array of the returned values.
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ var nodes = registry.map(function(w){ return w.domNode; }); });
Remove a widget from this WidgetSet. Does not destroy the widget; simply removes the reference.
Parameter | Type | Description |
---|---|---|
id | String |
A synthetic clone of array.some
acting explicitly on this WidgetSet
Parameter | Type | Description |
---|---|---|
func | Function | A callback function run for every widget in this list. Exits loop when the first true return is encountered. |
thisObj | Object |
Optional Optional scope parameter to use for the callback |
Convert this WidgetSet into a true Array
Work with the widget .domNodes in a real Array
require(["dijit/WidgetSet", "dijit/registry"], function(WidgetSet, registry){ array.map(registry.toArray(), function(w){ return w.domNode; }); });