jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – .modal(‘dispose’)做什么? Bootstrap 4大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
根据 .modal('dispose')的文档,破坏了模态.

但是当我使用创建一个eventListener时

$('#mymodal').on('hidden.bs.modal',function (event) {
    // Destroy modal
    $('#mymodal').modal('dispose');
});

模态仍然是文档的一部分.文档让我困惑,这个方法不用于从文档中删除模态吗?这种方法的目的是什么?

$('#mymodal').modal('show');

$('#mymodal').on('hidden.bs.modal',function (event) {
  console.log('Destroy modal');
  $('#mymodal').modal('dispose');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<div class="modal" tabindex="-1" role="dialog" id="mymodal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-priMary">Save changes</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

解决方法

它破坏了Bootstrap的Modal组件的jQuery实例.它不会从DOM中@L_551_3@modal标记.

大佬总结

以上是大佬教程为你收集整理的jquery – .modal(‘dispose’)做什么? Bootstrap 4全部内容,希望文章能够帮你解决jquery – .modal(‘dispose’)做什么? Bootstrap 4所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。