I have two Template.registerHelper
's in a template and this template is called on an events
event in another template as:
Template.myHome.events({
"click .examine": function(event){
Meteor.call('getDetailsUser',keyImg,keyUser, function(err,result){
if(err){
console.log(err.reason);
return;
}
Blaze.renderWithData(Template.see,result,myContainer);
})
});
In the template rendered, I have this html:
{{#if liked likes}}
<button type="button"><i class="fa fa-heart fa-2x"><span class="badge fontScale roboto">{{likes.length}}</span></i></button>
{{else}}
<i class="fa fa-heart fa-2x"><span class="badge fontScale roboto">{{likes.length}}</span></i>
{{/if}}
{{#if wanted user key}}
<button><i class="fa fa-tag fa-2x"></i></button>
{{else}}
<span><i class="fa fa-tag fa-2x"></i></span>
{{/if}}
The Template.registerHelper - wanted
works fine so if a user clicks the button, it reevaluates this condition to return false. However the Template.registerHelper - liked
does not reevaluate the condition on button click:
Template.registerHelper ('liked', (a) => {
var isLiked = true;
a.forEach(function(el){
if(Meteor.user()._id == el.userLike) {
isLiked = false;
}
});
return isLiked;
});
Template.registerHelper ('wanted', (a,b) => {
var wanted = Meteor.user().want;
var isWanted = true;
wanted.forEach(function(el){
if(a == el.usersType && b == el.match) {
isWanted = false;
}
});
return isWanted;
});
I know the Template.registerHelper - liked
works because I call it in another template and it’s fine.
What would prevent it working in this instance?