How to destroy a dynamically rendered template?

Hello! I have a parent template called “parent” and a bunch of child templates that are rendered inside parent,

<template name="parent">
    <div id="unique-id">
     ...
     ...
     ...
    {{> Template.dynamic template=currentScreen }}
    </div>
</template

I render parent dynamically as well by using:

templateID = Blaze.renderWithData(Template.parent, { _id: id, screen:['template1', 'template2', 'template3'] }, $(body)[0]);

// currentScreen is a helper function that will return a value from screen array

I can destroy the parent template by:

Blaze.remove(templateID);

but this doesn’t trigger Template.template1.onDestroy. so my question is how can trigger it or manually destroy a child template?

thanks in advance :slight_smile:

1 Like

Did you figure out a way around this ?