dojo.query
dojo.query() returns a list of DOM nodes based on a CSS selector.
dojo/query is the AMD module containing the query function in 1.7
dojo.forEach
Since the JavaScript forEach() function is not supported natively on every browser, dojo.forEach provides the standard JavaScript 1.6 forEach construct everywhere. dojo.forEach lets you apply a function to each element of an array, emulating a for loop.
dojo.forEach() cannot terminate a loop (except when throwing an exception). Use dojo.some() or dojo.every() instead.
The dojo.query and dojo.forEach example below retrieves the input elements of type "checkbox" within a node with id="sidebar". It then iterates thru the list and changes the input element's 'disabled' property.
var checkboxes = dojo.query("#sidebar input[type=checkbox]"); dojo.forEach(checkboxes,function(checkbox) { checkbox.disabled = !checkbox.disabled; });
http://dojotoolkit.org/reference-guide/1.7/dojo/query.html
http://dojotoolkit.org/reference-guide/1.9/dojo/query.html
http://dojotoolkit.org/documentation/tutorials/1.6/using_query/
https://dojotoolkit.org/reference-guide/1.7/dojo/forEach.html
dijit.findWidgets
Returns an array of all non-nested widgets inside the given DOM node.
var cpDivContainers = dijit.findWidgets(dojo.byId('divContainer')); dojo.forEach(cpDivContainers, function(cp) { //destroy the widget (remove from the registry) cp.destroyRecursive(); });
Another example:
dojo.forEach(dijit.findWidgets(dojo.byId('divContainer')), function(w) { w.destroyRecursive(); });
http://dojotoolkit.org/reference-guide/1.8/dijit/registry.html