【问题标题】:Pass msg_id with jQuery into Twitter Bootstrap modal使用 jQuery 将 msg_id 传递到 Twitter Bootstrap 模式
【发布时间】:2012-10-02 02:42:58
【问题描述】:

我有一个 jquery 模式。所以现在我想将 msg_id 的值传递给 modal。

HTML 代码:

<a data-toggle="modal" href="#com" id="<?php echo $msg_id; ?>">Comment</a>

--

<div id="com" class="modal hide fade in" style="display: none; ">
<div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
        <h3><?php echo $msg_id; ?></h3>
</div>

<div class="modal-body">
    <h4>Text in a modal</h4>
    <p>You can add some text here.</p>              
</div>

<div class="modal-footer">
    <a href="#" class="btn btn-success">Call to action</a>
    <a href="#" class="btn" data-dismiss="modal">Close</a>
</div>

这是截图。 如果我单击表 1 中的注释,它会显示并且我可以看到通过值。 但是如果我点击表 2 中的评论,它会显示与表 1 相同。应该不同,因为每个都有不同的 msg_id。

那么我如何将 msg_id 值传递给我的代码的情况下的模式? 感谢您的帮助。 谢谢

【问题讨论】:

标签: php jquery twitter-bootstrap


【解决方案1】:

您必须在 a 标签中添加一些类属性,例如“modal-toggler”

<a  class="modal-toggler" data-toggle="modal" href="#com" 
    id="<?php echo $msg_id; ?>">
    Comment
</a>

然后像这样调用一些 jQuery 脚本

<script type="text/javascript">
$(".modal-toggler").click(function(){
    var _id = $(this).attr("id");
    $("#com h3").text(_id);
    $("#com").show();
    return false;
});
</script>

【讨论】:

  • 我试过代码,它只显示 1 msg_id 虽然有一些消息。
  • 那么,你想看什么?此代码是否将锚 id 应用于您的模式?
  • 嗨,我给你我的案例的屏幕截图。在顶部看到它
猜你喜欢
  • 1970-01-01
  • 2016-11-11
  • 1970-01-01
  • 2020-10-21
  • 1970-01-01
  • 2014-10-03
  • 2014-08-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多