Meteor - handling events in nested templates... without polluting 'Session' variable -


i've come across situation several times , realise i'm not confident 'meteor/right' way handle it.

suppose have form several parts - each represented template - , within each part there more templates representing eg. datepickers etc.

<template name='myform'>     {{>partone}}     {{>parttwo}}     <button class='submit'>submit</button> </template>  <template name='partone'>     {{>widget}}     {{>widget}} </template>  <template name='widget'>     <input class='datepicker' /> </template> 

i want keep track of form user fills out - on level of 'myform' template - events happening @ level of 'widget'.

one solution keep seeing (e.g. in answer) put in global session variable. so

template.widget.events({     'click .select' : function(event, template){         var name = template.data.name;         session.set(name, $(event.currenttarget).val());     } }); 

and in myform should this

template.myform.rendered = function(){     tracker.autorun(function(){         var name = session.get('name');         //     }); } 

but forms getting more complicated, find turning mess on myform template level, while filling session variable data isn't application-global.

i'd grateful ideas on how others deal ! keeping templates , widgets modular while still being able follow , react triggered events parent templates...

you can use file-level reactivevar or reactivedict, instead of session object.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -