首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >流星-从备忘录列表中显示单个备忘录页

流星-从备忘录列表中显示单个备忘录页
EN

Stack Overflow用户
提问于 2014-09-19 03:02:38
回答 1查看 89关注 0票数 0

我现在正在拔头发。无法为我的备忘录应用程序显示单个备忘录详细页面。我尝试了几十种解决方案。有时我能看到一毫秒的数据,然后它就会消失。我确实在铁路线上

代码语言:javascript
复制
// router.js 

    this.route('memo',{
       path: '/memo/:_id', 
        data: function() { return Memos.findOne({id: this.params._id}); }
    });

我写了助手(不知道铁路由器为什么要处理这个问题,对吗?)

代码语言:javascript
复制
    //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);
    }**
});

整个列表的模板

代码语言:javascript
复制
    //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>

然后是单备注模板

代码语言:javascript
复制
//memo.html

<template name="memo">
    title : {{title}}
    <br>
    body: {{body}}

</template>

不能让这个起作用。我在这里错过了什么?控制台显示:"entering li body : zj9y3y3mNvQ6uK7Eg title: zxxxxxxxxxx" "**NaN**zxxxxxxxxxxxxxxx",所以它似乎检索正确的数据,但它没有被呈现(?),我也没有在所有消息体前面做'NaN‘是怎么回事。任何帮助如何使单一备忘录显示,非常感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-19 04:02:31

有一个错误:

代码语言:javascript
复制
Memos.findOne({id: this.params._id});

应该是

代码语言:javascript
复制
Memos.findOne({_id: this.params._id});

或者只是

代码语言:javascript
复制
Memos.findOne(this.params._id);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25925697

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档