简体   繁体   English

Xpages-打开对话框几秒钟,然后再次关闭它

[英]Xpages - Open a dialog for a few seconds and close it again

I want to open a dialog box that should be visible for a few seconds (2 seconds maybe) and then closes automatically. 我想打开一个对话框,该对话框应该会显示几秒钟(也许2秒钟),然后自动关闭。 Can anybody give me a hint how to solve that? 有人可以给我提示如何解决吗? Is there any timer function I can use? 我可以使用任何计时器功能吗?

You can use the client side function setTimeout() to achieve this. 您可以使用客户端功能setTimeout()实现此目的。 Insert following CSJS code to your button which opens the dialog box: 将以下CSJS代码插入到您的按钮中,以打开对话框:

setTimeout(function() {
        ... client action to hide dialog or XSP.partialRefreshGet/Post ...
    }, 2 * 1000);

The first parameter is the function which shall be executed at timeout and second parameter is the number of milliseconds for timeout. 第一个参数是应在超时时执行的功能,第二个参数是超时的毫秒数。

I've you're also looking for something like this, check this out: https://frostillic.us/f.nsf/posts/a-control-for-dojox.widget.toaster 我也正在寻找类似的内容,请查看以下内容: https : //frostillic.us/f.nsf/posts/a-control-for-dojox.widget.toaster

This uses the following component and works with dojo: http://livedocs.dojotoolkit.org/dojox/widget/Toaster 它使用以下组件并与dojo一起使用: http : //livedocs.dojotoolkit.org/dojox/widget/Toaster

You can use the Solution from Knut Hermann, but you should insert a clearTimeout() function to stop open and closing the dialog box 您可以使用Knut Hermann的解决方案,但应插入clearTimeout()函数停止打开和关闭对话框。

<xp:scriptBlock
id="scriptBlockRefresh">
<xp:this.value>
        <![CDATA[
            var myVar = setTimeout(function() {
                ... client action to hide dialog or XSP.partialRefreshGet/Post ...
            }, 2 * 1000)

            clearTimeout(myVar);
        ]]>
</xp:this.value>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM