【发布时间】:2017-08-03 23:12:14
【问题描述】:
我在让 autoform 挂钩工作时遇到问题。目前我正在使用这个快速表单。
{{>quickForm id="studentForm" collection="Students" type="insert" template="bootstrap3-horizontal" label-class="col-sm-3" input-col-class="col-sm-9"}}
我希望在成功提交表单时显示成功消息。目前我有一个使用此代码的事件:
Template.home.events({
"submit #student-form": function(event) {
event.preventDefault();
swal("Success!", "You have been added to the WaitList", "success")
}
});
我正在尝试像这样使用 autoform 钩子:
AutoForm.hooks({
studentForm: {
onSuccess: function(insert, result) {
swal("Success!", "You have been added to the wait list", "success")
}
}
})
目前这对我不起作用,我很困惑为什么这不起作用。 autoform 钩子 here 的文档。
对我的问题有什么想法吗?
【问题讨论】:
-
只是一个疯狂的猜测,但您是否尝试注释掉 preventDefault()?
-
是的,成功了。谢谢!
-
太好了,我会回答的
标签: javascript html meteor hook meteor-autoform