Reputation: 1563
I have a parent template which calls a child template. I want to kill the child template by the press of a button.
Parent Template
<template name="tracker">
<span id="destroyChild" class="btn" title="destroyTable"></span>
{{<child}}
</template>
Then, I have an event to attempt and destroy the child template
'click span[id=destroyChild]'(e, template) {
//This works to remove the Parent template
//Blaze.remove(template.view);
Blaze.remove('what do I put here?');
},
I can't find anything to use as a param to remove the child template. I keep getting Uncaught Error: Expected template rendered with Blaze.render
.
I gave the child template an Id and tried calling this with a selector
but no luck. Any ideas? Thanks!
Upvotes: 0
Views: 86
Reputation: 21364
You shouldn't imperatively modify your layout. Blaze is a reactive engine, so everything should be decided declaratively, e.g.:
<template name="tracker">
<span id="destroyChild" class="btn" title="destroyTable"></span>
{{#if show}}
{{> child}}
{{/if}}
</template>
Session.setDefault('show', true);
Template.tracker.helpers({
show() {
return Session.get('show');
}
});
...
'click span[id=destroyChild]'(e, template) {
Session.set('show', false);
},
Upvotes: 2