欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解處理bootstrap4不支持遠(yuǎn)程靜態(tài)框問(wèn)題

 更新時(shí)間:2018年07月20日 09:44:00   作者:棲遲於一丘  
這篇文章主要介紹了詳解處理bootstrap4不支持遠(yuǎn)程靜態(tài)框問(wèn)題,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

起步

我就是喜歡用新的,況且 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í)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論