【发布时间】:2015-12-20 07:46:55
【问题描述】:
我有一个带有更新 Autoform 的模板:
<template name = "editLocationPage">
<div class="flow-text">
{{#if Template.subscriptionsReady}}
<div>
<br>
{{#autoForm collection="Locations" doc=currentDoc id="editLocationPage" type="update"}}
<fieldset>
{{testDoc}}
<legend>Edit Location / Asset</legend>
{{> afQuickField name='id'}}
{{> afQuickField name='text'}}
{{> afQuickField name='description' rows=3}}
{{> afQuickField name='type'}}
{{> afQuickField name='parent'}}
</fieldset>
<button type="submit" class="btn waves-effect waves-light">Submit</button>
<button type="reset" class="btn waves-effect waves-light red">Reset</button>
{{/autoForm}}
</div>
{{/if}}
</div>
</template>
一些帮助订阅并将文档传递给模板:
Template.editLocationPage.onCreated(function() {
var self = this;
self.autorun(function() {
self.subscribe('singleLocation', Session.get("idTreeView").toString());
});
});
Template.editLocationPage.helpers({
currentDoc: function() {
return Locations.find({"id":Session.get("idTreeView").toString()}).fetch()[0];
}
});
架构:
// Data subset subscribed to on client
Meteor.publish('locations', function() {
return Locations.find({}, {fields: {
text: true,
id: true,
type:true,
parent:true
}});
});
Meteor.publish('singleLocation', function(locationId) {
return Locations.find({id:locationId});
});
文档没问题(findOne 返回一个有效的文档),但表单不起作用。有什么想法吗?
【问题讨论】:
-
控制台有错误吗?
-
debug.js:41 模板帮助程序中的异常:TypeError:无法在 bindDataContext (localhost:3000/packages/…) 处读取 Object.afFieldInputContext (localhost:3000/packages/…) 处未定义的属性“标签”...... ......其次是例外页面
-
也尝试通过这个而不是运气: Locations.find({"id":Session.get("idTreeView").toString()}).fetch()[0]
标签: meteor