Maksim  Savitskiy Maksim Savitskiy - 2 years ago 126
Javascript Question

Unregister Material Disign Lite component in Backbone view

I'm using MDL with Backbone.
How can i unregister components before removing view that contains any MDL component.

To register components i'm using

function from MDL. But without
appears memory leak.

I can't get MDL components that associated with current view to unregister them =(

Answer Source

I found solution of this problem. I just add this code in remove method of all my Backbone views:

var components = this.el.querySelectorAll('[data-upgraded]'); 
if (components.length > 0) {

This code find all upgraded elements in view and downgrade them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download