dso0139 2015-01-21 12:46
浏览 42

如何在smarty&Php中使用<a>为set query MySQL发送参数

i want create grid with bootstrap in smarty / php
in grid i have name, family, ... & edit button.
when i click in btn edit, modal popup open, but i don't know how sent record ID to function for set query & show in modal:
sample code:
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:

<!-- 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>
  • 写回答

1条回答 默认 最新

  • dqpc1845 2015-01-21 12:59
    关注

    The simpliest solution:

    • remove attributes data-toggle="modal" and data-target="#myModal"
    • Add data-id attribute for tag a
    • Add bind jquery to click for tag a
    • when user click to tag a:
      • Insert record ID into hidden text input in modal form
      • Run bootstrap modal manually $('#myModal').modal()

    Hope it will help

    EDIT:

    Also in documentation i see special event when modal run (probably it is more bootstrap.js way...):

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

    so you can use e.target to get attributes of tag a

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line