[英]Meteor autoform submit and modal dismissal
Using autoform I am trying to create a modal that will dismiss on submit only if the fields are valid. 我正在尝试使用自动表单创建一个仅在字段有效时才会在提交时关闭的模式。 If the fields are not valid I do not want the modal to dismiss.
如果这些字段无效,我不希望该模态消失。 In the format shown below it will always dismiss even when the values are not valid.
在下面显示的格式中,即使值无效,也将始终关闭。
<template name="insertForm">
{{#autoForm schema=schema id="insertForm" type="method" meteormethod="newC"}}
<fieldset>
{{> afQuickField name="Name"}}
{{> afQuickField name="Stuff"}}
<button type="submit" class="btn btn-primary" data-target="#formModal" data-toggle="modal">Submit</button>
</fieldset>
{{/autoForm}}
</template>
Use Hook to do this. 使用挂钩执行此操作。 this sample code may help you to understand :
此示例代码可以帮助您理解:
var insertFormhook = {
onSuccess: function(update, result) {
if(result){
// ...
Modal.hide('insertForm');
}
}
}
AutoForm.addHooks('insertForm',insertFormhook);
Basically i am using peppelg:bootstrap-3-modal which gives me easy to use bootstrap 3 modals. 基本上我正在使用peppelg:bootstrap-3-modal ,这使我易于使用bootstrap 3模态。
Cheers... 干杯...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.