twitter-bootstrap x 秒后关闭 Twitter Bootbox

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17762247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:38:58  来源:igfitidea点击:

Close Twitter Bootbox after x seconds

javascriptjquerytwitter-bootstrapbootbox

提问by davidOhara

Is it possible to close a twitter bootbox after 10 seconds?! i open it like this:

是否可以在 10 秒后关闭 Twitter 引导箱?!我是这样打开的:

bootbox.confirm("{{$steps[0]}}","accept","decline" ,function(result) {
    if (result) {

    }
}); 

回答by Scott

This code will close the open bootbox automatically after 10 seconds.

此代码将在 10 秒后自动关闭打开的引导箱。

window.setTimeout(function(){
    bootbox.hideAll();
}, 10000); // 10 seconds expressed in milliseconds

See the documentation here

请参阅此处文档

回答by bhagyas

I just committed a patch that would add this functionality to bootbox.

我刚刚提交了一个补丁,可以将此功能添加到 bootbox。

It is available on the link below.

它可以在下面的链接上找到。

https://github.com/bhagyas/bootbox/commit/72cd1ada43d3aa74f0dcfb10d66219fe208063af

https://github.com/bhagyas/bootbox/commit/72cd1ada43d3aa74f0dcfb10d66219fe208063af

After adding this patch to your bootbox.js, you could set an additional timeOut option in your options for bootbox.

将此补丁添加到 bootbox.js 后,您可以在 bootbox 的选项中设置额外的超时选项。

bootbox.dialog({
    message  : "Your operation completed successfully.",
    timeOut : 2000
});

Cheers.

干杯。