【问题标题】:Autoform Hooks onSuccessAutoform Hooks onSuccess
【发布时间】: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


【解决方案1】:

它显然被事件的 preventDefault() 阻止了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 2015-03-20
    • 1970-01-01
    • 2015-12-01
    • 2011-11-09
    • 2014-12-09
    • 2010-11-17
    相关资源
    最近更新 更多