Joined November 2012
·

Jake Hoffner

CodeWars
·
Los Angeles, CA
·
·
·

I'm aiming to switch away from using CanJS to Backbone on my project and the zombie issue is something that bothered me about Backbone. CanJS doesn't have this problem. The reason for it is that it ties into the JQuery $.cleanData method, which gets fired after an element is removed from the DOM (using html(), remove(), etc). I would look into utilizing the same type of thing in BackBone (which I plan to once I get a chance to convert my code over to BackBone).

Taken from CanJS codebase

    // Memory safe destruction.
var oldClean = $.cleanData;

$.cleanData = function( elems ) {
    $.each( elems, function( i, elem ) {
        if ( elem ) {
            can.trigger(elem,"destroyed",[],false);
        }
    });
    oldClean(elems);
};
Achievements
40 Karma
0 Total ProTip Views