Eliminar plantilla insertada en meteor 0.8.0
Estoy insertando plantillas usando UI.render () y UI.insert ().
Cuando traté de eliminar la plantilla que inserté, parece permanecer en la memoria y no se llama al método destruido.
De acuerdo con la documentación, debería limpiar la propiedad si uso jquery para eliminar el elemento.
Lo estoy probando con el siguiente código:
test.html:
<head>
<title>removeTest</title>
<style>
#content {
height: 500px;
width: 500px;
background-color: gray;
}
</style>
</head>
<body><div id="content"></div></body>
<template name="foo"><div id="{{id}}">Foo</div></template>
test.js:
if (Meteor.isClient) {
UI.body.events({
"click": function(event) {
var instance = UI.renderWithData(Template.foo, { });
UI.insert(instance, $("#content")[0]);
}
});
Template.foo.created = function() {
this.data.id = "handle";
var self = this;
this.x = setInterval(function() { console.log("running...") }, 1000);
setTimeout(function() { $("#handle").remove() }, 1000);
};
Template.foo.destroyed = function() {
// never called.
clearTimeout(this.x);
};
}
¿Qué hice mal?
Gracias.