詳解處理bootstrap4不支持遠(yuǎn)程靜態(tài)框問題
起步
我就是喜歡用新的,況且 bs4 出來也很久了,用了一段時間后發(fā)現(xiàn)它并不支持遠(yuǎn)程靜態(tài)框了,查了一下這部分已經(jīng)被移除了。
所以,以前的 <a data-toggle="modal" href="remote.html" rel="external nofollow" data-target="#modal">Click me</a>
這種寫法就沒法用了,因此這部分要手動處理下。
處理
處理的方式其實也比較簡單,改成手動 load 而已,按照 bs3 的效果是遠(yuǎn)程結(jié)果取代靜態(tài)框中的 modal-content
部分:
<button data-toggle="modal" data-remote="remote.html" data-target="#modal">Click me</button> <script> $('#modal_result').on('hidden.bs.modal', function (e) { $(this).find('.modal-body').html(' 等待結(jié)果,請稍后...'); $(this).removeData('bs.modal'); }).on('show.bs.modal', function (e) { // 手動處理下載入過程 var button = $(e.relatedTarget); var modal = $(this); modal.find('.modal-content').load(button.data("remote")); }); </script>
完整demo
<!DOCTYPE html> <html > <head> <meta charset="utf-8"> <title>Codeply preview</title> <link rel="external nofollow" rel="stylesheet"> </head> <body > <button data-toggle="modal" class="btn btn-primary" data-remote="a.html" data-target="#modal">Click me</button> <div id="modal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title"></h4> </div> <div class="modal-body"> 等待結(jié)果,請稍后... </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button> </div> </div> </div> </div> <!--scripts loaded here--> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://cdn.bootcss.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script> $('#modal').on('hidden.bs.modal', function (e) { $(this).find('.modal-body').html(' 等待結(jié)果,請稍后...'); $(this).removeData('bs.modal'); }).on('show.bs.modal', function (e) { var button = $(e.relatedTarget); var modal = $(this); modal.find('.modal-content').load(button.data("remote")); }); </script> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS中的public和private對象,即static修飾符
先看下面的例子,它將告訴我們在JS世界中也有C#里的public , private ,及static等2012-01-01js獲取本機(jī)的外網(wǎng)/廣域網(wǎng)ip地址完整源碼
通過js獲取本機(jī)的外網(wǎng)和廣域網(wǎng)ip地址的方法有很多,本文為大家介紹個不錯的方法,希望對大家有所幫助2013-08-08JavaScript高級程序設(shè)計 事件學(xué)習(xí)筆記
JavaScript高級程序設(shè)計 事件學(xué)習(xí)筆記,需要的朋友可以參考下。2011-09-09