我现在正在拔头发。无法为我的备忘录应用程序显示单个备忘录详细页面。我尝试了几十种解决方案。有时我能看到一毫秒的数据,然后它就会消失。我确实在铁路线上
// 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‘是怎么回事。任何帮助如何使单一备忘录显示,非常感谢。
发布于 2014-09-19 04:02:31
有一个错误:
Memos.findOne({id: this.params._id});应该是
Memos.findOne({_id: this.params._id});或者只是
Memos.findOne(this.params._id);https://stackoverflow.com/questions/25925697
复制相似问题