0

我是新手。我有一种情况,我必须显示引导模式,当我单击该模式上的任何按钮时,我必须在第一个模式下方显示另一个模式(不可堆叠)。如果我关闭 1st Modal 2nd Modal 必须上去替换 1st Modal 的位置。

可能吗 ?

有什么帮助吗?

4

1 回答 1

3

您可以监听第一个模型的“关闭”事件来打开第二个模型:

将函数绑定到 Twitter Bootstrap 模式关闭

$('#my-modal').on('hidden.bs.modal', function () {
  window.alert('hidden event fired!');
})

手动打开第二个模型:

$('#otherModel').modal('toggle') 

一个例子:

您的 HTML 代码:

<!-- Button trigger modal -->
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-lg">Launch demo modal</a>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

Javascript:

  $('#myModal').on('hidden.bs.modal', function() {
    $('#myModal2').modal("toggle");
  });
于 2013-10-30T09:10:59.063 回答