我现在拉出我的头发。 无法显示我的备忘录应用程序的单一备忘录详细页面。我尝试了数十种解决方案。有时我可以看到数据一毫秒然后消失。 我在铁路由器流星 - 从备忘录列表中显示单个备忘录页
// router.js
this.route('memo',{
path: '/memo/:_id',
data: function() { return Memos.findOne({id: this.params._id}); }
});
我写的帮手做路线(不知道为什么,如果铁路由器处理这个,是吧?)对整个列表
//helpers.js
Template.memo.helpers({
memo: function(){ return Memos.findOne({id: this._id})}
});
Template.memos.events({
'click #remove-memo': function(event,template){
console.log('memo removed : ' + this._id);
Memos.remove(this._id);
},
**'click #li-body': function(event, template){
console.log('entering li body : ' + this._id + ' title: ' + this.title);
Router.go('/memo/'+this._id);
}**
});
模板
//memos.html
<template name="memos">
<ul>
{{#each memos}}
<li class="notes-main">
<span id="remove-memo" class="ex icon-close"></span>
<a class="no-decoration" **href="{{pathFor 'memo' }}**">
<span id="li-body" class="no-decoration">
<span class="notes-title">{{this.title}}</span>
<span class="notes-author">{{author}}</span>
<span class="notes-body-prev">{{body}}</span>
</span>
</a>
</li>
{{/each}}
</ul>
</template>
然后单个备忘录模板
//memo.html
<template name="memo">
title : {{title}}
<br>
body: {{body}}
</template>
无法让此工作。我在这里错过了什么? 控制台显示:"entering li body : zj9y3y3mNvQ6uK7Eg title: zxxxxxxxxxx" "**NaN**zxxxxxxxxxxxxxxx"
因此,它似乎检索正确的数据,但它没有得到渲染(?),也没有'NaN'在所有消息体前做的事情。 任何帮助如何获得单一的备忘录,非常感谢。
你有一个'在你的HTML中,每memos',但我没有看到'备忘录'助手。这是在你的代码? – 2014-09-19 03:41:27
是的,备忘录帮手工作得很好。我可以看到所有备忘录的清单,问题是单一的详细备忘录。 – yoK0 2014-09-19 03:45:26