I use a layout in which i display a navigation bar with links for pages, and i have rules in routes.js like this:
FlowRouter.route('/url1', {
name: 'test.url1',
action: function(params) {
BlazeLayout.render("layout1t", {main: "url1"});
}
});
FlowRouter.route('/url2', {
name: 'test.url2',
action: function(params) {
BlazeLayout.render("layout1t", {main: "url2"});
}
});
FlowRouter.route('/url3', {
name: 'test.url3',
action: function(params) {
BlazeLayout.render("layout1t", {main: "url3"});
}
});
layout1.html:
<ul>
<li>
<a href="/url1">
</a>
</li>
<li>
<a href="/url2">
</a>
</li>
<li>
<a href="/url3">
</a>
</li>
</ul>
<h1>{{pagename}}</h1>
layout1.js
Template.layout1.helpers({
var route = FlowRouter.current().route.name;
console.log(route);
if(route === "test.url1"){
return "this is url1";
}
if(route === "test.url2"){
return "this is url2";
}
if(route === "test.url3"){
return "this is url3";
}
return "";
});
As you can see i have a helper in layout js from which i want to get current route name and return appropriate text to be displayed on page. For some reason route stays the same.
For example. i go in browser http://localhost:3000/url1
after that i see in console test.url1
Then if i CLICK AND NOT GO IN BROWSER URL on a links /url2
/url3
nothin happens helpers not getting called for some reason. All other data is reactive i checked, only helpers in template seems to not be reactive for some reason. Is it normal behaviour and how to solve this?