詳解處理bootstrap4不支持遠(yuǎn)程靜態(tài)框問(wèn)題
起步
我就是喜歡用新的,況且 bs4 出來(lái)也很久了,用了一段時(shí)間后發(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> 這種寫(xiě)法就沒(méi)法用了,因此這部分要手動(dòng)處理下。
處理
處理的方式其實(shí)也比較簡(jiǎn)單,改成手動(dòng) 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é)果,請(qǐng)稍后...');
$(this).removeData('bs.modal');
}).on('show.bs.modal', function (e) {
// 手動(dòng)處理下載入過(guò)程
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é)果,請(qǐng)稍后...
</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é)果,請(qǐng)稍后...');
$(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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Bootstrap Table中的多選框刪除功能
- bootstrap 彈出框modal添加垂直方向滾軸效果
- bootstrap treeview 樹(shù)形菜單帶復(fù)選框及級(jí)聯(lián)選擇功能
- bootstrap中selectpicker下拉框使用方法實(shí)例
- 解決在Bootstrap模糊框中使用WebUploader的問(wèn)題
- React BootStrap用戶(hù)體驗(yàn)框架快速上手
- bootstrap 點(diǎn)擊空白處popover彈出框隱藏實(shí)例
- Bootstrap 模態(tài)框多次顯示后臺(tái)提交多次BUG的解決方法
- 響應(yīng)式框架Bootstrap柵格系統(tǒng)的實(shí)例
相關(guān)文章
jsp 網(wǎng)站引入外部css或者js失效問(wèn)題解決
這篇文章主要介紹了jsp 網(wǎng)站引入外部css或者js失效問(wèn)題解決的相關(guān)資料,需要的朋友可以參考下2016-10-10
JS獲取數(shù)組最大值、最小值及長(zhǎng)度的方法
這篇文章主要介紹了JS獲取數(shù)組最大值、最小值及長(zhǎng)度的方法,涉及JavaScript遍歷數(shù)組及l(fā)ength屬性的相關(guān)使用技巧,非常簡(jiǎn)潔實(shí)用,需要的朋友可以參考下2015-11-11
原生JavaScript+LESS實(shí)現(xiàn)瀑布流
這篇文章主要介紹了原生JavaScript+LESS實(shí)現(xiàn)瀑布流的方法,附上了具體實(shí)例,這里推薦給有需要的小伙伴。2014-12-12
javascript實(shí)現(xiàn)淘寶幻燈片廣告展示效果
這篇文章主要介紹了javascript實(shí)現(xiàn)淘寶幻燈片廣告展示效果的方法,以實(shí)例形式完整講述了javascript實(shí)現(xiàn)幻燈效果的javascript、css及html實(shí)現(xiàn)技巧,需要的朋友可以參考下2015-04-04
JavaScript對(duì)象詳解之對(duì)象屬性的添加
這篇文章主要給大家介紹了關(guān)于JavaScript對(duì)象詳解之js對(duì)象屬性的添加的相關(guān)資料,在JavaScript中對(duì)象是通過(guò)鍵值對(duì)來(lái)存儲(chǔ)數(shù)據(jù)的一種數(shù)據(jù)類(lèi)型,可以通過(guò)直接給對(duì)象添加屬性的方式來(lái)增加對(duì)象的屬性,需要的朋友可以參考下2023-07-07
JS中的public和private對(duì)象,即static修飾符
先看下面的例子,它將告訴我們?cè)贘S世界中也有C#里的public , private ,及static等2012-01-01
js獲取本機(jī)的外網(wǎng)/廣域網(wǎng)ip地址完整源碼
通過(guò)js獲取本機(jī)的外網(wǎng)和廣域網(wǎng)ip地址的方法有很多,本文為大家介紹個(gè)不錯(cuò)的方法,希望對(duì)大家有所幫助2013-08-08
JavaScript高級(jí)程序設(shè)計(jì) 事件學(xué)習(xí)筆記
JavaScript高級(jí)程序設(shè)計(jì) 事件學(xué)習(xí)筆記,需要的朋友可以參考下。2011-09-09

