Is there a way in Dojo to find all the descendants of widgets in a DOM element?

Is there a way in Dojo to find all the descendants of widgets in a DOM element? I used the example below, it will list only the children of this element, in this case any widgets that are children of the document object, but not all descendants or nested widgets. Hope this is clear.

var widgets = dijit.findWidgets(dojo.doc); dojo.forEach(widgets, function(w) { console.log(w); }); 

I could just write my own recursive function, but I want me not to miss the Dojo method that already does this.

Many thanks

+6
source share
1 answer

Hmm, dijit.findWidgets(parentWidget.domNode) ?

Change Oh, now I have found findWidgets that is not looking recursively.

I checked the dijit.findWidgets source code and all it does is check the nodes with the widgetid attribute that are presented in the dijit registry. The next version uses dojo.query to repeat the same search:

 function findEvenTheNestedWidgets(innitialNode){ return dojo.query("[widgetid]", innitialNode) .map(dijit.byNode) .filter(function(wid){ return wid;}) //filter invalid widget ids that yielded undefined } 
+9
source

Source: https://habr.com/ru/post/900022/


All Articles