【问题标题】:MeteorJS get data passed to the templateMeteorJS 获取传递给模板的数据
【发布时间】:2015-08-11 14:56:49
【问题描述】:

我是 MeteorJS 的新手。我尝试使用下载和报告按钮做列表:

列表模板:

<template name="myBooks">
    <div class="container">
        <h2>My books</h2>
        <div class="list-group">
            {{#each myBooks}} {{> myBookListItem}} {{/each}}
        </div>
    </div>
</template>

myBookListItem 模板:

<template name="myBookListItem">
    <a class="list-group-item">
        <span class="badge badge-success">{{downloads}}</span>
        <span class="badge badge-error">{{warnings}}</span>

        <h4 class="list-group-item-heading "><i>{{title}}</i> - {{author}}</h4>
        <p class="list-group-item-text ">{{description}}</p>
        <button type="submit" id="download" class="btn btn-success">Download</button>
        <button type="submit" id="report" class="btn btn-danger">Report</button>
    </a>
</template>

我的藏书项目还包含“链接”属性,它是可下载 pdf 的 url - 我如何在#download 按钮单击时访问它?

if (Meteor.isClient) {
    Template.myBookListItem.events({
        'click #download': function (event) {
            //What_kind_of_magic_shoud_i_use_here()
            alert();
        },
        'click #report': function (event) {
            alert();
        },

    });
}

任何人都可以帮助我:)?

【问题讨论】:

  • 好吧,这很愚蠢,只需要使用“this.link”:D
  • 您可能希望将其添加为答案,以便其他人可以看到您的问题不再需要答案。是的,可以回答您自己的问题。

标签: templates meteor parameters get click


【解决方案1】:

我只需要使用this.link

【讨论】:

    猜你喜欢
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-09
    • 2014-05-20
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    相关资源
    最近更新 更多