简体   繁体   English

Bootstrap 3 Modal:`data-remote`正在加载图像

[英]Bootstrap 3 Modal: `data-remote` loading image

My website uses data-remote on a bootstrap modal to load images. 我的网站在引导程序模式下使用data-remote加载图像。 You can see the code in this question ( https://stackoverflow.com/a/21199283/2537559 ) which I answered myself. 您可以在此问题中看到代码( https://stackoverflow.com/a/21199283/2537559 ),我已回答了自己。 The thing is that it might take a second or two to load the info so I would like to add a loading image (preferably the one used in fancybox). 事实是,加载信息可能需要一两秒钟,因此我想添加一个加载图像(最好是在fancybox中使用的图像)。 Im not 100% sure how to do this. 我不是100%知道该怎么做。 It might be to add the image and when modal-open loads then remove the image. 可能是添加图像,然后在modal-open载荷下移除图像。 Im not 100% sure on how to do this and any help will be great! 我不确定如何做到这一点,任何帮助都会很大! Thanks! 谢谢!

According to the docs , you can use the event listeners: 根据docs ,您可以使用事件监听器:

show.bs.modal and shown.bs.modal show.bs.modalshown.bs.modal

$(function()
{
    $(".modal").on("show.bs.modal",function()
    {
        // add loader indicator
    });
    $(".modal").on("shown.bs.modal",function()
    {
        // remove loader indicator
    });
}

Your own answer to your other question does not have any javascript. 您自己对其他问题的答案没有任何JavaScript。 So it's difficult to provide an answer that can be integrated into your current solution. 因此,很难提供可以集成到当前解决方案中的答案。

A loaded.bs.modal event will be present in Bootstrap v3.1.0 (see https://github.com/twbs/bootstrap/issues/10911 ); Bootstrap v3.1.0中将出现一个loaded.bs.modal事件(请参阅https://github.com/twbs/bootstrap/issues/10911 ); listening for this event is preferable to listening to shown.bs.modal . 监听此事件比监听shown.bs.modal

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

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