Skip to content

Instantly share code, notes, and snippets.

@applehat
Last active December 14, 2015 01:49
Show Gist options
  • Save applehat/5009022 to your computer and use it in GitHub Desktop.
Save applehat/5009022 to your computer and use it in GitHub Desktop.
Recursively kill elements in Alloy with Global Function.
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