Last active
December 27, 2015 14:09
-
-
Save dylans/7338074 to your computer and use it in GitHub Desktop.
dijit recursive getAllChildren example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); | |
}); |
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
registry.findWidgets(this.containerNode);
https://github.com/dojo/dijit/blob/1.9.1/registry.js#L84-L113