Reputation: 149
I am trying to insert various templates depending on which button is clicked. For this I created an event that sets a session variable with the id of the button.
'click .task-option-button': function (e) {
var template = e.target.id;
Session.set('addTaskTemplate', template);
console.log(template);
}
and a helper that returns the session variable
addTaskTemplate: function () {
var taskTemplate = Session.get('addTaskTemplate');
return taskTemplate;
},
and then the template gets inserted like this
{{> Template.dynamic template= "{{addTaskTemplate}}"" }}
However, clicking the button doesn't add the template. When I put
{{> Template.dynamic template= "SomeStaticTemplate" }}
it works. Also using {{addTaskTemplate}} as a normal variable in <p></p>
tags works and returns the id of the button as a string. Is there anything I am missing here?
Upvotes: 0
Views: 47
Reputation: 1303
{{> Template.dynamic template= addTaskTemplate }}
will do. Just remove the {{ }}
brackets.
Upvotes: 2