【问题标题】:how can i send parameters with <a> for set query MySQL in smarty & Php如何使用 <a> 发送参数以在 smarty 和 PHP 中设置查询 MySQL
【发布时间】:2015-01-21 12:46:19
【问题描述】:

我想在 smarty / php 中使用引导程序创建网格
在网格中,我有姓名、家庭、... & 编辑按钮
当我在 btn 编辑中单击时,模式弹出窗口打开,但我不知道如何发送 记录 ID 以在模式中设置查询和显示:
示例代码:
www.bootply.com/webdeveloper/iQrK1Yxlkk

btn:

<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>

【问题讨论】:

    标签: php mysql twitter-bootstrap bootstrap-modal


    【解决方案1】:

    最简单的解决方案:

    • 删除属性data-toggle="modal"data-target="#myModal"
    • 为标签a添加data-id属性
    • 为标签a添加绑定jquery到click
    • 当用户点击标记 a 时:
      • 以模态形式将记录 ID 插入隐藏文本输入中
      • 手动运行引导模式$('#myModal').modal()

    希望对你有帮助

    编辑:

    在文档中我也看到了模态运行时的特殊事件(可能它更像是 bootstrap.js 方式...):

    $('#myModal').on('show.bs.modal', function (e) {
       // get record ID here
    })
    

    所以你可以使用 e.target 来获取标签a的属性

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-29
      相关资源
      最近更新 更多