gpt4 book ai didi

javascript - meteor 将数据从链接传递到模态

转载 作者:行者123 更新时间:2023-11-29 17:06:07 24 4
gpt4 key购买 nike

我正在尝试将 href 中的 ID 传递到单击链接时打开的模式。

我有模式弹出好的,但是我得到的不是链接中的 id,而是父页面的 ID。

我的链接代码是

 <table class="table table-striped table-condensed">
<tbody
<tr>
<th>Posted</th>
<th>ID</th>
</tr>
{{#each quotes}}
<tr>
<td>{{submittedText}}</td>
<td><a href="#showQuote" class="showQuote" data-toggle="modal">{{_id}}</a></td>
</tr>
{{/each}}
</tbody>

表格中有正确的报价 ID,但我不知道如何让此报价 ID 出现在打开的结果模式中。

我尝试如下在助手中捕获点击事件

  'click #showQuote' : function(t,e) {
console.log(this);
console.log(t);
console.log(e);
debugger;
}

但这是父 ID,而不是引用 ID(而且这似乎只有在我关闭对话时才会触发)。

请问我如何传递这个?

最佳答案

session 变量是一种方法,但如果您使用 peppelg:bootstrap-3-modal包,您可以将父上下文传递给 show 函数。

JavaScript

Template.template_with_modal_link.events({
'click . showQuote': function() {
Modal.show('<ModalName>', this); // parent context this
} });

html

<template name="<ModalName>">
<!-- modal format -->
</template>

关于javascript - meteor 将数据从链接传递到模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24586213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com