简体   繁体   English

jQuery到Bootstrap Modal的延迟不起作用

[英]JQuery delay to Bootstrap Modal not working

I'm trying to find an easy way to auto close my modals after openning and while i can do intervals w/c will require a few lines of code, i thought that the delay() of jquery would've been easier.. 我试图找到一种简单的方法来打开后自动关闭我的模态,虽然我可以做间隔w / c将需要几行代码,但我认为jquery的delay()会更容易。

so in the trigger function for when the modal is displayed I have this: 所以在触发函数中显示模态时,我有这个:

$("#modalUserConfirm").delay(3000).modal('hide');    

but this is not working.. the modal closes as soon as it opens.. 但这不起作用..模态一打开就关闭。

Perhaps it's just not compatible? 也许只是不兼容?

Try 尝试

$("#modalUserConfirm")
    .delay(3000)
    .queue(function(){ $(this).modal('hide').dequeue(); });

Demo: http://jsfiddle.net/DerekL/TUy9p/ 演示: http//jsfiddle.net/DerekL/TUy9p/

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

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