【发布时间】:2017-04-23 02:50:16
【问题描述】:
我有一个带有一些链接的导航栏。链接都触发相同的模式,但我需要根据链接在模式内显示不同的信息。我更喜欢非 jQuery 解决方案,但如果有必要,我会接受。
我试过了……
firstpage.php
<li><a href="#theModal?viewmessages=mymessages" data-toggle="modal">My Messages</a></li>
<li><a href="#theModal?viewnotifications=mynotifications" data-toggle="modal">My Notifications</a></li>
<!---Modal -->
<div id="theModal" class="modal fade text-center">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<?php include 'modal.php';?>
</div>
</div>
</div>
<!-- Modal -->
modal.php
<!--
=============================
ISSET_GET MESSAGES
=============================-->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Messages</h4>
</div>
<div class="modal-body">
<p>some text here</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
<!--
=============================
ISSET_GET NOTIFICATIONS
=============================-->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Notifications</h4>
</div>
<div class="modal-body">
<p>some text here</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
【问题讨论】:
-
你想将什么数据传递给模态?
-
在
firstpage.php中设置的变量应该可以在modal.php中访问。有多少内容需要改变?您可以将所有模式都放在页面底部。并在您的每个链接中设置data-target="#the-id-of-your-modal"。看看我的例子w3schools.com/code/tryit.asp?filename=FEWFXWWS2918
标签: php jquery twitter-bootstrap bootstrap-modal