关闭Dojo中的所有模态对话框

时间:2021-06-21 19:39:41

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.

有谁知道如何关闭Dojo创建的所有模态对话框?显然以前有一个dojo.popup.closeAll函数,但在Spring JS附带的最新版本的Dojo API中不再可用。

5 个解决方案

#1


3  

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.

这是正确的....那个方法不再存在的原因是从1.0开始弹出一个弹出窗口的人负责关闭它。这是我所做的架构改变。

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

#2


3  

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(); 
});

#3


1  

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

看来现在唯一有效的方法是跟踪你的对话框,并在需要时使用hide()关闭它们。

#4


0  

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.

我不知道这是否有用,但我倾向于每个页面只使用一个对话框(因为它是模态的)。所有对话框的内容都是来自服务器的xhrGot,我将整个dojo时间花在一个页面的生命周期中,一次又一次地回收相同的对话框,只是改变它的属性:它的href和它的标题。我发现这个工作以及有几个对话框。

#5


0  

dojo >= 1.10:

dojo> = 1.10:

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

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

#1


3  

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.

这是正确的....那个方法不再存在的原因是从1.0开始弹出一个弹出窗口的人负责关闭它。这是我所做的架构改变。

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

#2


3  

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(); 
});

#3


1  

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

看来现在唯一有效的方法是跟踪你的对话框,并在需要时使用hide()关闭它们。

#4


0  

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.

我不知道这是否有用,但我倾向于每个页面只使用一个对话框(因为它是模态的)。所有对话框的内容都是来自服务器的xhrGot,我将整个dojo时间花在一个页面的生命周期中,一次又一次地回收相同的对话框,只是改变它的属性:它的href和它的标题。我发现这个工作以及有几个对话框。

#5


0  

dojo >= 1.10:

dojo> = 1.10:

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

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

相关文章