简体   繁体   中英

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.

Cheers...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM