Skip to content

Instantly share code, notes, and snippets.

@dylans
Last active December 27, 2015 14:09
Show Gist options
  • Save dylans/7338074 to your computer and use it in GitHub Desktop.
Save dylans/7338074 to your computer and use it in GitHub Desktop.
dijit recursive getAllChildren example
define([
"dojo/_base/array",
"dojo/_base/declare",
"dojo/_base/lang"
], function (arrayUtil, declare, lang) {
return declare(null, {
getAllChildren: function () {
// puts all children into a flat array
console.log(this.getNestedChildren);
return (this.hasChildren()) ? this.getNestedChildren(this) : [];
},
getNestedChildren: function (parent) {
var children = parent.getChildren();
var nested = [];
arrayUtil.forEach(children, function(child) {
if (child.hasChildren()) {
nested.concat(lang.hitch(this, "getNestedChildren", child));
}
});
return children.concat(nested);
}
});
});
@neonstalwart
Copy link

registry.findWidgets(this.containerNode); https://github.com/dojo/dijit/blob/1.9.1/registry.js#L84-L113

@neonstalwart
Copy link

oh, wait... findWidgets is not recursive. the deprecated getDescendants might be useful too but it finds all widgets rather than just the ones designated as "children"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment