Last active
December 14, 2015 01:49
-
-
Save applehat/5009022 to your computer and use it in GitHub Desktop.
Recursively kill elements in Alloy with Global Function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alloy.Globals.gc = function(ob, parent) { | |
if (ob.children) { | |
for (var c = (ob.children.length - 1); c >= 0; c--) { | |
Alloy.Globals.gc(ob.children[c], ob); | |
} | |
} | |
if (parent) { | |
parent.remove(ob); | |
ob = null; | |
} | |
} | |
/* | |
=== USAGE === | |
Generally I use it in the close event on windows. | |
*/ | |
$.someWindow.addEventListener('close',functiin(){ | |
Alloy.Globals.gc($.someWindow); | |
}); | |
/* It can also be used on single views, when removing them... */ | |
$.someWindow.remove($.someView); | |
Alloy.Globals.gc($.someView); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment