Now I had a similar problem before I got this error:
Exception in the template helper: TypeError: cannot read property 'profile' undefined
The same thing happens again, but in a second order, which contains other user profile information (the first profile is determined). How do I get it to be reprocessed in {{#each orders}}?
It also seems that info.firstName, lastName and building are 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!
source
share