bootstrap modal loading content via remote url, wait for modal to fully load content until being shown

两盒软妹~` 提交于 2019-12-21 05:25:14

问题


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.

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?


回答1:


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' );
    });
});


来源:https://stackoverflow.com/questions/16531234/bootstrap-modal-loading-content-via-remote-url-wait-for-modal-to-fully-load-con

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!