Question

Does anybody know how I can close all modal dialogs created by Dojo ? Apparently there used to be a dojo.popup.closeAll function, but this is no longer available in the latest version of the Dojo API that comes with Spring JS.

Was it helpful?

Solution

That's right.... the reason that method isn't there anymore is that from 1.0, whoever opens a popup is in charge of closing it. It's an architecture change I made.

Most widgets (like Menu) monitor when they've been blurred, and then close their child popup. So, you could probably get the effect you wanted by switching focus to the document itself, or to some random node. Of course that's a workaround.

Bill

OTHER TIPS

This will find all literal Dialogs in a page and hide them:

dijit.registry.filter(function(w){ 
    return w && w.declaredClass == "dijit.Dialog" 
}).forEach(function(w){ 
    w.hide(); 
});

It appears that the only valid way now is to keep track of your dialogs and close them all when needed using hide().

I don't know if this is of any use, but I tend to use only one dialog for each page (since it is modal). All the dialogs' content is xhrGot from the server, and I spend the entire dojo-time within a page's lifecycle recycling again and again the same dialog, merely changing its attributes: its href and its title. I find this works as well as having several dialogs.

dojo >= 1.10:

define(['dijit/registry'], ...

registery.toArray().filter(function(w){ 
    return w && w.declaredClass == "dijit.Dialog" 
}).forEach(function(w){ 
    w.hide(); 
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top