javascript - meteor js (meteor-autoform + iron router) pass value after form is submitted -
after form validated redirect user specific page , display values. don't know if way think use correct one. here's tried already:
creating form in template:
{{> quickform collection="transactions" id="inserttransaction" type="insert"}}
then created hook called when form validated & inserted
autoform.addhooks('inserttransaction',{ onsuccess: function(data){ router.go('one', null, {query: 'amount=' + data->amount}); console.log(data); } });
@michel floyd
my one.html
<template name="one"> <div class="row"> <div class="col-sm-7"> 1 page... </div> <div class="col-sm-5"> {{ amount }} </div> </div> </template>
my code home.js (client/home.js):
autoform.addhooks('inserttransaction',{ onsuccess: function(data, data2, data3){ result = transactions.findone(data2, { amount: 1}); amount = (result["amount"]); router.go('one',{amount: amount}); } });
here's router code:
router.route('/one/:amount',()=>{ name: 'one', this.render('one', {data: this.params.amount}); });
i "no route found named "one"" time.
first create route amount
param, i.e.
router.route('/one/:amount',()=>{ name: 'one', this.render('one', {data: this.params.amount}); });
then use router.go('one',{amount: amount});
note there's no underscore next amount
in this.params.amount
Comments
Post a Comment