dimanche 22 février 2015

Route.go doesn't work in form submit


I'm new to meteor and javascript and I'm developing an app just for fun.


I'm using meteor with ionic. I have a simple form:



<form>
....
<label class="item item-input">
<input type="text" name="title" placeholder="Post Title" required>
</label>
....
<label class="item item-input" >
<textarea name="message" required></textarea>
</label>
...
<button class="button icon-left ion-android-upload button-large create-button button-positive">
Create
</button>
.....
<form>


and the relative helper look like this:



Template.boxSubmit.events({
"click .create-button": function (e) {
var box = createBoxFromForm($('form').serializeArray());
Boxes.insert(box);
Router.go('/');
}};


The record is inserted but there's no redirection to "/". If I insert:



e.preventDefault();


Record is inserted, redirection works but I don't get the basic automatic form validation (null field, with errors reported to users).


Is there a way to have both?





Aucun commentaire:

Enregistrer un commentaire