I’ve been trying to figure out whats going on with this dynamic template for a good deal of time and can’t seem to make any progress. I asked a question on stack and no one has been able to give me a solution. I have the following template within which I would like to display one of four other templates.
<template name = "selectFrame">
<div class = "container">
<div class = "frameCarousel">
{{> Template.dynamic template=active data=this}}
</div>
</div>
</template>
Active is a template helper that determines which template should be shown.
What is your Session variable? Is it a string? Or is it a template object?
The way I have personally done this in the past is like below:
<template name = "selectFrame">
<div class = "container">
<div class = "frameCarousel">
{{> getTemplate data=this}}
</div>
</div>
</template>
Template.selectFrame.helpers({
getTemplate: function() {
return Template[Session.get('board')]; // Where Session.get('board') returns a string that accesses the Template object
}
});
The session variable is set from the id of a button on a previous wizard page. I tried your edit and it still only allows the default template to be rendered. As ‘board’ changes, which I checked and it does, no new template is rendered when advancing to the wizard step where the selectFrame template is called
I am using Template.dynamic and it works as advertised (example). Using nested dynamic templates I found out is a sure way to crash your app/browser, however.
So i think the problem is that the button isn’t within the same template. I’m working on creating a wizard with jQuery Steps. So the button that sets the variable is within the template for step 1 and the dynamic template is in the template for step 2. I want the template in step 2 to be dynamic because the choice from step 1 determines which template gets loaded in step 2. Any ideas?