0
我有yield
部分模板:流星:访问上下文(模板)数据呈现回调
{{>yield}}
在yield
我展示形式
this.route('editCategory', {
path: '/panel/category/:_id/edit',
layoutTemplate: 'panelTemplate',
template: 'editCategoryTemplate',
data: function(){
return Categories.findOne(this.params._id);
},
});
有一个选择框,(我选择父类别)和几个选项。我选择先前选择的选项与脚本:
Template.editCategoryTemplate.rendered = function(){
$('#categoryParent option[value="'+ this.data.parent +'"]').prop('selected', true);
};
,一切工作正常,但重新加载页面后出现错误:
Exception from Deps afterFlush function: this.data is null
任何帮助将不胜感激。
也许这个页面可以提供一些帮助http://www.meteorpedia.com/read/TypeError_-_Cannot_read_property_nodeName_of_null – 2014-09-02 20:40:32
我的猜测是渲染器上的回调函数在模板实例呈现时调用,但可能数据还没有被检索,因此没有可用的“父”。 – 2014-09-02 20:52:35
我有类似的猜测 - 但如何解决这个问题?如何迫使流星等待/检索这些数据? (它已保存在类别文档集合中) – mrmnmly 2014-09-02 20:55:17