Now I had a similar problem before where I was getting this error:
Exception in template helper: TypeError: Cannot read property 'profile' of undefined
The same thing is happening again but on the second order, which contains another users profile information (the first profile is defined). How would I get it to re-render in {{#each orders}}?
It also appears that info.firstName, lastName, and building gets called 3 times for some reason when there are only 2 orders...
In HTML:
<template name="orderItem">
<section>
<form role="form" id="ordersList">
<div>
{{#each orders}}
<input type="text" name="name" value="{{info.firstName}} {{info.lastName}}">
{{/each}}
</div>
<div>
{{#each orders}}
<input type="text" name="building" value={{info.building}}>
{{/each}}
</div>
<div>
{{#each orders}}
<input type="text" name="featuredDish" value={{featuredDish}}>
{{/each}}
</div>
</form>
</section>
</template>
In javascript:
Template.orderItem.orders = function() {
var todaysDate = new Date();
return Orders.find({dateOrdered: {"$gte": todaysDate}});
};
Template.orderItem.info = function() {
var userId = this.userId;
var user = Meteor.users.findOne(userId)
var firstName = user.profile.firstName;
var lastName = user.profile.lastName;
var building = user.profile.building;
return {
firstName: firstName,
lastName: lastName,
building: building
}
};
Appreciate the help!