【发布时间】:2015-05-24 04:30:17
【问题描述】:
大家下午好。
当我转到包含通过通知的评论的页面时,我正在尝试为评论项目着色。 - 如 fb 或堆栈溢出。
除了我上面提到的部分之外,我一切正常。
通知事件
Template.notification.events({
'click a':function() {
var commentTemplate = this.commentId;
console.log(commentTemplate); //Target commentId returns successfully
//Code here needed
//to color comment when page moves to
//coresponding page.
}
Template.commentList
//HTML
{{#each comments}}
{{> commentItem}}
{{/each}}
//JS
comments: function(){
return Comments.find({postId:this._id});
}
我也尝试使用this._id通过console.log获取相应的commentItem的id。
所以我想知道的是,
有没有办法从通知链接this.commentId 并使用相应的_id 访问<template name = "commentItem">。然后使用.addClass之类的东西来操纵它的element/dom。
请把我推向正确的方向!
【问题讨论】:
标签: javascript jquery mongodb meteor meteor-blaze