【发布时间】:2015-07-10 21:22:12
【问题描述】:
所以我有这段代码,当我点击View Receipt 链接时,收据图像的外部链接会以模式弹出。我正在使用树枝和苗条的框架。
这是我的带有树枝的 html 文件:
{% for r in results %}
<a data-toggle="modal" href="/user/receipt/{{r.accountID}}" data-target="#myModal">View Receipt</a>
{% endfor %}
{% block script %}
<!-- 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> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /.modal -->
{% endblock %}
route.php 代码:
$app->get('/user/receipt/:id', function($id) use($app) {
$db = new db();
$bind = array(
":aid" => $id
);
$result = $db->select("accounts", "accountID = :aid", $bind);
$app->render('screenshot.html', array('result' => $result));
});
screenshot.html 代码:
{% for r in result %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<img src="/assets/img/receipts/{{r.receipt}}" class="img-responsive">
</div>
{% endfor %}
现在一切正常。图像显示在模态中。问题是...当我第一次在页面加载时单击View Receipt 链接时,所有其他链接将包含相同的图像,而不是基于accountID 的图像。所有链接都继承了被单击的第一个链接。我做错了什么?
【问题讨论】:
-
你有问题的图片吗?
-
页面加载完毕后,是否所有链接都显示各自的收据图片?
-
@noahdotgansallo 页面加载后,当你点击一个链接时,它会根据模态的链接显示接收图像,w/c 是正确的.. 但是当你点击另一个链接时,它显示了被点击的第一张收据的图像。
标签: php jquery twitter-bootstrap bootstrap-modal slim