Hello,
I am experiencing an odd issue with an autoform inside a modal. I am using the peppelg:bootstrap-3-modal package alongside autoform/simple-schema.
in my template i have:
{{#autoForm id="placeForm" schema=placeSchema class="form-new-place"}}<div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Add a New Place(click)</h4> </div>
<div class="modal-form">
<div class="modal-body">
<div class="row"> <div> {{> afQuickField name="Name"}} </div> </div>
</div> <!-- end modal-body --> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary" id="save">Save</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> </div>
</div> {{/autoForm}}
</div>
In the .js backing the template I have:
Template.placeModal.events({
“submit form”: function(event, template){
event.preventDefault();
console.log(“form submit”);
},“click #save”: function(event, template){
// event.preventDefault();
console.log(“Clicked submit”);
}}); // end events
The modal is being called from the parent Template via an event:
‘click .new-place-modal’: function(event, template){
event.preventDefault(); Modal.show("placeModal");
},
With the above configuration - the modal is rendered properly, validation runs, but no actual submit event occurs - I also tried with the click event which always fires whether the form is valid or not.
If I replace the autoform, with a standard HTML form, then the submit event runs no issue (but then I have to implement validation manually which I’m hoping to avoid)…
Not sure why the submit event will not run…
Thanks