javascript - Standard pattern to redirect a submit form after checking the insert was successful, on Meteor with AutoForm & Iron Router? -



javascript - Standard pattern to redirect a submit form after checking the insert was successful, on Meteor with AutoForm & Iron Router? -

i'm using meteor autoform & iron router.

i have autoform inserting record, , want redirect page view record after successful insert. what's accepted way this?

if utilize standard autoform insert like:

{{#autoform collection="articles" id="articlesubmit" type="insert"}}

i can't see how can redirect?

if utilize 'method' type this:

{{#autoform collection="articles" id="articlesubmit" type="method"}}

then have write insert method not particularly dry.

a form form, if utilize type="method" thats means using meteor.method this, , form handle you, meteor.call

now if want router.go(), need write js code, can utilize hooks, wich come autoform package, example

articles.hooks({ contactform: { onsubmit: function (insertdoc, updatedoc, currentdoc) { if (somehandler(insertdoc)) { this.done(); articles.clean(doc); / can more logic here, cleaning form. router.go('thepath'); } else { this.done(new error("submission failed")); } homecoming false; } } });

so don't need mutual 'submit #articlesubmit' utilize auto forms api better.

javascript meteor iron-router meteor-autoform

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -