繁体   English   中英

我如何在Twitter Bootstrap中拥有两个不同的模式

[英]How can I have two different Modals in Twitter Bootstrap

因此,如果我有两个不同的模型,则第二个模型中的内容不会显示,而是第一个模型的内容。 如何获得内容不同的两个单独的模型

示例模型1:

<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">modal 1</a>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div>

示例模型2:

<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn btn-danger" data-toggle="modal">modal 2</a>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">this is different</h3>
  </div>
  <div class="modal-body">
    <p>this ones different but yet when you click it the content of the first Model appears.</p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">diffent</button>
    <button class="btn btn-danger">Quit</button>
  </div>
</div>

我的目标是当我单击第二个模式按钮时,内容将成为第二个模式中的内容,而不是第一个模式中的内容。 我希望他们俩都不同。

使用2个不同的模式ID。

<!-- Button to trigger modal -->
<a href="#myModal1" role="button" class="btn" data-toggle="modal">modal 1</a>

<!-- Modal -->
<div id="myModal1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
...

<!-- Button to trigger modal -->
<a href="#myModal2" role="button" class="btn" data-toggle="modal">modal 2</a>

<!-- Modal -->
<div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
...

Bootply上的演示: http ://bootply.com/80525

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM