我想在 smarty/php 中使用引导程序创建网格
在网格中,我有名字,家庭,...和编辑按钮。
当我在BTN edit中单击时,模态弹出窗口打开,但我不知道如何发送记录ID以用于设置查询并在模态中显示:
示例代码:
www.bootply.com/webdeveloper/iQrK1Yxlkk
顺便说一句:
<a href="" class="btn btn-success" data-toggle="modal" data-target="#myModal" data-backdrop="static">
Edit User
</a>
模 态:
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
username: ...
<br>
Password: ...
<br>
avatar: ...
<br>
...
</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>
</div>
</div>
最简单的解决方案:
data-toggle="modal"
和data-target="#myModal"
删除属性- 为标记
a
添加data-id
属性 - 将绑定 jquery 添加到标记
a
的click
- 当用户单击以标记 A 时:
- 将记录 ID 插入到模式形式的隐藏文本输入中
- 手动运行引导模式
$('#myModal').modal()
希望会有所帮助
编辑:
同样在文档中,我在模式运行时看到了特殊事件(可能它更引导.js方式......
$('#myModal').on('show.bs.modal', function (e) {
// get record ID here
})
因此,您可以使用 e.target 获取标签a
的属性