javascript - Meteor - 模板助手参数(空格键)

标签 javascript node.js twitter-bootstrap meteor

我需要一些关于如何解决我的问题的想法。我有以下带有表格的 html 模板。它显示 5 行,在每行的末尾(在最后一个 td 中)有一个按钮触发 Bootstrap 模式(弹出窗口)。 我正在使用空格键 {{#each}} 遍历所有游标,但问题出在模式上。它只显示第一行的数据,每一行记录相同的数据。 这是因为模式的 ID 对于每条记录都是相同的(它是第一个,#subsPopup)。我需要以某种方式为每一行传递不同的 ID,例如 #subsPopup{{var}}。知道我该怎么做吗?

<!-- subscribers table -->
<table class="table table-hover">
   <thead>
      <tr>
         <th>Firstname</th>
         <th>Lastname</th>
         <th>Email</th>
         <th>Created</th>
         <th>Modified</th>
         <th>Mailing lists</th>
      </tr>
   </thead>
   <tbody>
      {{#each subsList}}
      <tr>
         <td>{{firstName}}</td>
         <td>{{lastName}}</td>
         <td>{{email}}</td>
         <td>{{createdDate}}</td>
         <td>{{modifiedDate}}</td>
         <!-- Trigger the modal (popup window) with a button -->
         <td>
            <button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#subsPopup">Show</button>
            <!-- Modal -->
            <div id="subsPopup" class="modal fade" role="dialog">
               <div class="modal-dialog">
                  <!-- Modal content-->
                  <div class="modal-content">
                     <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Mailing List for <b>{{firstName}} {{lastName}}</b> ({{email}})</h4>
                     </div>
                     <div class="modal-body">
                        <p>{{mailLists}}</p>
                     </div>
                     <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                     </div>
                  </div>
               </div>
            </div>
         </td>
      </tr>
      {{/each}}
   </tbody>
</table>

最佳答案

您的订阅集合可能有 _id 字段,因此您可以尝试输出 {{_id}}

关于javascript - Meteor - 模板助手参数(空格键),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31538841/

相关文章:

javascript - 单击 Canvas 中的对象时出现奇怪的错误?

mysql - Angular 或 Node.js 在 Node 重启时将重复项插入 Mysql

html - 找出边界来自哪里

Rails Bootstrap 中简单表单的 CSS 样式

javascript - NodeJS 等待 mySQL 查询完成

javascript - 在 AngularJS 中获取选定的选项

javascript - 类型错误 : Cannot assign to read only property - Karma

javascript - CSS。让父级有子级宽度

javascript - jQuery.parseJSON(); 的反向操作是什么?

node.js - NodeJS 服务函数未定义