繁体   English   中英

Bootstrap:使用模式显示动态数据时遇到麻烦

[英]Bootstrap: Trouble using modal for showing dynamic data

我有一个使用PHP创建的列表

while($row = $result->fetch_assoc()){ //$row is a row fetched from my database
<tr>
   <td><?php echo $row['id']?></td>
   <td><?php echo $row['name']?></td>
   <td><?php echo $row['surname']?></td>
   <td><a href="#Modal" <?php echo "id= " . $row['username'] ?> class="btn btn-small btn-info" data-toggle="modal" > Vedi</a></td>
</tr>
}

模态是这样的:

<div id="Modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
      <div class="modal-header">
        <a class="close" data-dismiss="modal" aria-hidden="true">×</a>
        <h3 id="myModalLabel">user information</h3>
      </div>
      <div class="modal-body" id="loadInfo">
        <div class="row-fluid">
          <div class="span12">

         <!-- my php code here -->

        </div>
       </div>
     </div>
</div>

我的php代码必须转给精确的用户。 因此,我需要Modal可以接收此ID,以便执行适当的php代码。

如何获得此结果?

将用户信息的值分配给javascript变量。 将数据属性添加到模式切换按钮,例如data-user_id=<?php echo $row['id']; ?> data-user_id=<?php echo $row['id']; ?>并创建一个jQuery单击处理程序以更新模式的内容以匹配您单击的按钮。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM