Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get all widgets inside an element

Tags:

dojo

From the dojo documents on dijit.registry, I see the forEach method accepts a last parameter thisObject. But it doesn't way what that object is. Is it a dijit widget or a dojo object?

I want to destroy all widgets inside an element (that will be replaced by AJAX) so they can be parsed again without conflicting id's.

dijit.registry.forEach(function(w) {
    w.destroyRecursive();
}, dojo.byId("ajaxElement"));

But this destroys ALL widgets on the page...

like image 654
peirix Avatar asked May 31 '10 08:05

peirix


1 Answers

The thisObject is the scope object to invoke the function passed in as the first parameter of forEach.

A couple of solutions you can use in this case:

1) Use dijit.findWidgets to find all the dijits in a DOM node and destroy them one by one. dijit.findWidgets returns array of widgets which takes domnode as a parameter 2) dojo.parser.parse returns an array of all the dijits that it creates, store that array and destroy the dijits before you call dijit.parser.parse again.

3) Use dijit.registry.filter to filter out the dijits you want to keep.

like image 73
Alex Cheng Avatar answered Oct 13 '22 09:10

Alex Cheng