通过远程URL引导模式加载内容,等待模式完全加载内容,直到显示 [英] bootstrap modal loading content via remote url, wait for modal to fully load content until being shown

查看:85
本文介绍了通过远程URL引导模式加载内容,等待模式完全加载内容,直到显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过远程url将内容加载到引导模式中,但是问题是模式窗口打开了,但是没有加载内容.

i'm able to load content via a remote url into a bootstrap modal, but the problem is the modal window opens up, but the content is not loaded.

一旦加载了内容,模态的主体就会更新,并且高度会扩展以适合模态的内容.

Once the content is loaded the body of the modal is updated and the height expands to fit the content of the modal.

但是,我只想在内容完全加载后才显示模态,并可能在模态加载时显示动画gif.

However, i'd like to only display the modal once the content is fully loaded, and maybe display an animated gif while the modal is loading.

我看了看文档,但是一旦加载了模态,我没有看到关于回调的任何信息.我希望可以保留模式,直到触发回调并显示它为止. 我该怎么办?

I've looked at the docs, but i didn't see anything there about maybe a callback once the modal is loaded. I was hoping to maybe keep the modal hidden until the callback was fired and show it. how can i do this?

推荐答案

我感谢上面的评论.我使用以下JavaScript存储了锚标签的远程URL,这些锚标签使用数据属性('data-href')和锚类名称为'popup-links'来触发弹出窗口.

I got it thanks to the above comments. I stored the remote urls for the anchor tags that trigger a popup using a data attribute ('data-href') with the anchors class name as 'popup-links' using the following javascript:

$jq191('.popup-links').on( 'click', function( e ){
    var remote= $jq191( this ).data( 'href' );
    $jq191('.modal-body').load( remote, function( e ){
        $jq191( '#myModal' ).modal( 'show' );
    });
});

这篇关于通过远程URL引导模式加载内容,等待模式完全加载内容,直到显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆