Hi Experts… I am novice user and trying to show different templates inside a template on clicking on a button. Setting and retrieving values from session is working fine. When loading the form I have set a display vairiable false and clicking a button I set the same session variable false. The value changes and it shows up properly in the getsetter in chrome browser. But, the following code always goes through the else part, never executes the if part, regardless of the session variable. Can you help…
Using iron router.
route.js
Router.route('page01', {
path: '/page01',
template: 'page01',
onBeforeAction: function(){
Session.set('newDeal', false);
this.next();
}
});
page01.js
=======
Template.page01.events({
'click .new-deal': () => {
Session.set('newDeal', true);
}
page01.html
==========
<template name='page01'>
Welcome to my page!!
<button class="new-deal">Click for New</button>
{{#if .Session.get 'newDeal'}}
{{ >NewPage}}
{{else}}
My content goes here
{{/if}}
</template>
NewPage.html
=============
<template name='NewPage'>
Here you can enter new page details...
<button class="close-deal"><i class="fa fa-close"></i></button>
</template>
NewPage.js
============
Template.NewPage.events({
'click .fa-close': function() {
Session.set('newDeal', false);
}
});
What is going wrong here. I can see the values changes from false to true and back to false upon clicking the new button and close button. Meteortoys getSetter shows appropriates values, but the template never honor those values and the if condition never goes to if section, it always executes the else section in the page01.html template.