I have a template for a back button I've been reusing:
<template name="btnBack" label="" path="">
<a href="" data-path="{{path}}" class="btn btn-info btn-small" role="button">
<span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span> {{label}}
</a>
</template>
I pass it two fields, label and path statically.
My intention is to pass the static path field to Iron-Router to change the template rendered.
Setting href to {{pathFor '{{path}}'}}does not work.
Neither does defining the attribute onclick as Router.go('{{path}}').
In my third attempt, I passed the path to a data attribute:
data-path="{{path}}"
And then I reference this attribute from within a template helper:
Template.btnBack.events({
'click a': function(event, template) {
var path = ''+event.target.dataset.path;
console.log(path);
Router.go(path);
}
});
The console.log statement runs correctly, and outputs the statically-defined path in Google Chrome's console window.
Router.go however, does nothing - it doesn't even throw an error for an incorrect path in the console.
Here is how I instantiate the template:
{{> btnBack label="Back" path="home"}}
What am I doing wrong?
Could you try setting the link to