编辑:我确实将action="/results"
添加到表单元素,但它没有做任何事情。我还在我的路线上设置了页面/results
。
Meteor的新手,我正在开发一个收集多个类别的表单条目的应用程序。表单是自定义构建的:
/*------------------- Template.html ----------------------------*/
<form class="word_of_day">
<div class="page 1 view">
<h1>Word of the day</h1>
<p>Enter the word and fill out the fields as you go.</p>
<input type="text" name="word" placeholder="Word of the day" />
</div>
<div class="page 2">
{{> day_two}}
</div>
<div class="page 3">
{{> day_three}}
</div>
<div class="page 4">
{{> day_four}}
</div>
<div class="page 5">
{{> day_five}}
<div class="error"></div>
<div class="pull-down">
<span>Would you like to send this to yourself? (not required)</span>
<input type="text" name="user_email" placeholder="Your Email" />
</div>
<button type="submit">Submit</button>
</div>
</form>
/*---------------------- app.js ---------------------------------------*/
Template.form.events({
"submit .word_of_day":function(event){
event.preventDefault();
});
目前我的表单将数据推送到我创建的集合中,但我无法弄清楚如何在提交后重定向表单。我在应用程序上设置了流量路由器,不确定是否有帮助。我感谢任何帮助和指导!
答案 0 :(得分:0)
在你的活动中
"submit .word_of_day":function(event){
event.preventDefault();
Meteor.call('updateYourData', $(event.target).serializeArray(), function(err, res){
if (!err) {
FlowRouter.go('path/to/some-where');
}
});
}