Meteor - data not available with Iron Router -
i trying achieve pretty simple: load template , fill data. however, template rendered several times, , first time null
data.
i found various posts issue stating rendering occurs every time subscription adds record clients database, , tried applying proposed solutions, still have first rendering without data. how can fix that?
router.configure({ layouttemplate: 'layout', loadingtemplate: 'loading', notfoundtemplate: 'notfound' }); router.route('/team/:_id/cal', { name: 'calendar', waiton: function() { return [ meteor.subscribe('userteams',meteor.user()._id), meteor.subscribe('teamusers', this.params._id)]; }, action : function () { console.log("action:"+this.ready()); if (this.ready() && template.currentdata != null) { this.render(); } }, data: function(){ var team = teams.findone({_id:this.params._id}) console.log(json.stringify(team)); return team; } }
);
console output
navigated http://localhost:3000/team/paemezbavgemwbnmy/plan router.js:33 undefined router.js:33 {"_id":"paemezbavgemwbnmy","name":"superteam","createdat":"2015-10-22t11:51:10.994z","members":["t6mpawqj75j2hgpi6","4t3stxaar9if4sk99","dde2djq3wjl2rfb43"]} router.js:26 action:true router.js:33 {"_id":"paemezbavgemwbnmy","name":"superteam","createdat":"2015-10-22t11:51:10.994z","members":["t6mpawqj75j2hgpi6","4t3stxaar9if4sk99","dde2djq3wjl2rfb43"]}
Comments
Post a Comment