【发布时间】:2017-03-31 01:36:44
【问题描述】:
我的路线中有这个:
Router.map(function() {
...
this.route('studentEdit', {
path: '/student/:_id/edit',
data: function() {
return Students.findOne(this.params._id);
},
});
this.route('studentDetail', {
path: '/student/:_id',
data: function() {
return Students.findOne(this.params._id);
}
});
...
});
我在我的模板中使用 autoform:
{{#autoForm collection="Students" id="studentEdit" doc=this type="update"}}
{{> afQuickField name='name'}}
{{> afQuickField name='phone'}}
{{> afQuickField name='address' rows=6}}
{{> afQuickField name='remarks' rows=6}}
<button type="submit" class="btn waves-effect waves-light"><i class="material-icons">save</i></button>
{{/autoForm}}
编辑页面加载良好,带有预填充的字段。当我保存时,它确实保存了,但它不会重定向到详细信息页面,并在控制台中返回此错误:
Exception in delivering result of invoking '/students/update': Error: Missing required parameters on path "/student/:_id". The missing params are: ["_id"]. The params object passed in was: {}.
更新 现在可以路由到详细信息页面,但控制台中仍然存在错误。我肯定错过了什么。这是我为使其暂时工作所做的工作:
var moveOnRouter = {
onSuccess: function(formType, result) {
Router.go('studentDetail', {_id: this.docId});
}
}
AutoForm.addHooks('studentEdit', moveOnRouter);
【问题讨论】:
-
你的
router.go()带你去哪里详细路线? -
在哪里添加 Router.go()?
标签: meteor iron-router