Pregunta

I wish to use jsViews in a widget that can be added/removed from the DOM multiple times.

If the widget runs code like this during creation:

if(!$.link.widgetTemplate)
{
   $.templates({ widgetTemplate: "#widgetTemplateSrc" });
}

$.link.widgetTemplate("#myElement", someData);

Would $("#myElement").remove(); cause a memory leak or would jsViews get properly disposed?

How do you unload jsviews if you do not wish to remove #myElement from the DOM?

¿Fue útil?

Solución

Yes, removing elements using jQuery methods such as .remove(), .empty(), .html() will trigger disposal in JsViews, and should not lead to memory leaks.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top