Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击关闭按钮将关闭所有引导模型_Javascript_Html_Jquery_Vue.js_Bootstrap 4 - Fatal编程技术网

Javascript 单击关闭按钮将关闭所有引导模型

Javascript 单击关闭按钮将关闭所有引导模型,javascript,html,jquery,vue.js,bootstrap-4,Javascript,Html,Jquery,Vue.js,Bootstrap 4,对于这些代码,有一个按钮“启动模式”打开模型,然后在模型中,还有一个按钮“启动模式2”打开模型上的新模型(只需调用模型2)当我单击model2上的关闭按钮时,所有模型都将取消关闭。我怎样才能解决这个问题? 请注意,我需要将模型2放入模型中以显示数据。 谢谢。 × 情态标题 对话框/模式的内容位于此处。 × 第二模态标题 对话框/模式的内容位于此处。 问题在于您将第二个模态放在第一个模态的内部。Bootstrap只关闭关闭按钮所在的所有模态,因此如果嵌套它们,则第二个关闭按钮将关闭所


对于这些代码,有一个按钮“启动模式”打开模型,然后在模型中,还有一个按钮“启动模式2”打开模型上的新模型(只需调用模型2)
当我单击model2上的关闭按钮时,所有模型都将取消关闭。我怎样才能解决这个问题?
请注意,我需要将模型2放入模型中以显示数据。
谢谢。


×
情态标题
对话框/模式的内容位于此处。





× 第二模态标题 对话框/模式的内容位于此处。
问题在于您将第二个模态放在第一个模态的内部。Bootstrap只关闭关闭按钮所在的所有模态,因此如果嵌套它们,则第二个关闭按钮将关闭所有外部模态。
要解决此问题,只需将整个
div#myModal2
向下移动到第一个
div#myModal
下,使它们成为单独的元素。 像这样:

<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>

<div class="modal" id="myModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h4 class="modal-title">Modal title</h4>
        </div><div class="container"></div>
        <div class="modal-body">
          Content for the dialog / modal goes here.
          <br>
          <br>
          <br>
          <br>
          <br>
          <a data-toggle="modal" href="#myModal2" class="btn btn-primary">Launch modal2</a>
          <div class="modal" id="myModal2" data-backdrop="static">
            <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">Second Modal title</h4>
                  </div><div class="container"></div>
                  <div class="modal-body">
                    Content for the dialog / modal goes here.
                  </div>
                  <div class="modal-footer">
                    <a href="#" data-dismiss="modal" class="btn">Close</a>
                    <a href="#" class="btn btn-primary">Save changes</a>
                  </div>
                </div>
              </div>
          </div>
        </div>
        <div class="modal-footer">
          <a href="#" data-dismiss="modal" class="btn">Close</a>
          <a href="#" class="btn btn-primary">Save changes</a>
        </div>
      </div>
    </div>
</div>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/js/bootstrap.min.js"></script>