【发布时间】:2014-10-09 03:19:21
【问题描述】:
我有这样的事情:
Template.todoList.helpers({
todos: function() {
return Todos.find({}); // Returns records with a todoText, ownerId and done field.
}
});
然后在模板中我使用{{#each}} 块来列出待办事项。但如果他们是done,我希望能够通过复选框进行更改。如果我只是在{{#each}} 块中添加这样的复选框,它将正确显示初始状态,但如果我切换复选框,记录将不会更新。我需要跟踪记录的_id,但我应该将它存储在哪里?如果我能找到正确的_id,剩下的就很简单了:
Template.todoList.events({
'change .doneCheckbox': function(event) {
var todoId = ??;
Todos.update(todoId, {$set: {done:event.target.checked}});
}
});
我会在?? 的位置插入什么?
【问题讨论】:
标签: meteor meteor-blaze