【发布时间】:2016-12-04 17:54:54
【问题描述】:
我想要做的是创建一个带有流星自动表单的表单,它将用户重定向到提交时新生成的路由。我的想法是,我可以将提交的 _id 用于 Iron:router 参数。我到目前为止看起来如下:
创建表单
Submits = new Meteor.Collection('Submits');
Submits.allow({
insert: function(username, doc){
return !!username;
}
});
SubmitSchema = new SimpleSchema({
title: {
type: String,
label: "Title"
},
subject:{
type: String,
label: "Subject"
},
summary:{
type: String,
label: "Summary"
},
author:{
type: String,
label: "Author",
autoValue: function() {
return this.userId
},
autoform: {
type: "hidden"
}
},
createdAt: {
type: Date,
label: "Created At",
autoValue: function(){
return new Date()
},
autoform: {
type: "hidden"
}
}
});
Submits.attachSchema( SubmitSchema );
路由
Router.route('/submit', {
layoutTemplate: 'submitLayout',
waitOn: function() { return Meteor.subscribe("Submits"); },
loadingTemplate: 'loading'
});
Router.route('/submit/:_id', {
name: 'formDisplay',
data: function() {
return Submits.findOne({this.params._id});
}
});
然后我只有平均发布和查找调用。我的问题是我不确定如何在提交时执行重定向,也不确定如何在新生成的路由上显示表单结果。
任何帮助将不胜感激。
【问题讨论】:
标签: javascript meteor iron-router meteor-autoform