我正在使用Meteor与AutoForm和铁路由器.
我有一个用于插入数据的autoform,我想重定向到成功插入后添加的数据页面.我该怎么办?
这是For:
{{#autoForm collection="Products" id="add" type="insert"}}
<h4 class="ui dividing header">Products Information</h4>
{{> afQuickField name='name'}}
{{> afQuickField name='info'}}
<button type="submit" class="ui button">Insert</button>
{{/autoForm}}
Run Code Online (Sandbox Code Playgroud)
铁路由器:
Router.route('/products/:_id', {
name: 'page',
data: function() { return Products.findOne(this.params._id);}
});
Run Code Online (Sandbox Code Playgroud)
回调/钩
AutoForm.hooks({
add: {
onSuccess: function(doc) {
Router.go('page', ???);
}
}
});
Run Code Online (Sandbox Code Playgroud)