Hey guys,
is there any method that I can call to destroy a template? I’m using a dynamic template to show a user profile in a modal. Problem is, if I visit a second user, the template instance of the first one is still available and I get the old positions in the picture slider (means he shows me picture 3 instead of picture 1). So I want to destroy the template if the user closes my popup.
My current solutions is this:
<div class="popup" id="userPopup">
{{> Template.dynamic template=showProfilePop.template data=showProfilePop.data}}
</div>
Here is the helper:
Template.registerHelper('showProfilePop', function () {
if(!Session.get('profile_view'))
{
return {template:null,data:null};
}
else
{
return {template:'profile',data: Meteor.users.findOne(Session.get('profile_view'), {reactive: false})};
}
});
…and if I open a profile popup:
'click .open-profile': function (e) {
var self = this;
Session.set("profile_view", false);
Meteor.subscribe("userProfile", this._id, function () {
Session.set("profile_view", self._id);
myApp.popup("#userPopup");
});
}
I set profile_view to false, to destroy the current profile template - but is there any better/easier way to solve this?