因此,如果我有两个不同的模型,则第二个模型中的内容不会显示,而是显示第一个模型的内容。如何获得具有不同内容的两个单独模型
示例模型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>
我的目标是当我点击第二个模态按钮,使内容成为第二个模态中的内容,而不再是第一个模态中的内容。我希望他们两者都不同。
答案 0 :(得分:1)
使用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