Route to the new data submitted by Meteor autoform using iron router?

大憨熊 提交于 2019-11-29 10:14:20

The AutoForm hook will return you the docId. See: https://github.com/aldeed/meteor-autoform#callbackshooks

this.docId: The _id attribute of the doc attached to the form, if there is one, or for an type='insert' form, the _id of the newly inserted doc, if one has been inserted.

So use:

Router.go('page',{_id: this.docId});

According to the doc on github, signatures changed: don't forget to declare the forms or null to apply the hooks.

for all forms

AutoForm.addHooks(null,{
    onSuccess: function(formType, result) {
        Router.go('page',{_id: this.docId});
    }
});

for specific form

AutoForm.addHooks(['yourForm'],{
    onSuccess: function(formType, result) {
        Router.go('page',{_id: this.docId});
    }
});

Best is to check the up to date signatures: https://github.com/aldeed/meteor-autoform#callbackshooks

onSuccess: function(formType, result) {
    Router.go(
        ['adminDashboard', result, 'Edit'].join(''), 
        {_id: this.docId}
    );
},
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!