I want to show a button in my template which is shown or not dependent on a session
value being true
or false
. However when I want to set the session to false in events it does not happen:
<template name="Home">
{{#if reload}}
<a class="btn btn-primary fontScale reloadBtn" href="#" id="reload"><i class="fa fa-refresh fa-lg"></i> Reload</a>
{{/if}
</template>
Template.Home.helpers({
reload: function(){
.........
(imgCount1 > imgCount) ? Session.set('more',true):Session.set('more', false);
return Session.get('more');
}
});
Template.Home.events({
......
"click #reload": function(){
Session.set('more', false);
}
});
How can I set the session variable back to false
after the button had been clicked?
I guess your helper is keeping the session variable to true. When you click the button, you are setting the session variable, but not the image count. If that's the case, just put some logging in both the click event and on the helper, and you might see one overwriting the value from the other.