Skip to content

Instantly share code, notes, and snippets.

@bsstoner
Created April 14, 2015 17:54
Show Gist options
  • Save bsstoner/1371e0f31539f7be2982 to your computer and use it in GitHub Desktop.
Save bsstoner/1371e0f31539f7be2982 to your computer and use it in GitHub Desktop.
!function destroyViews(views){
if (!views) { return; }
var v;
if ($.isArray(views)) {
for (var i=0; i<views.length; i++) {
v = views[i];
if(v && $.isArray(v)){
destroyViews(v);
} else {
v && v.destroy && v.destroy();
}
}
views = null;
} else {
for(var c in views){
v = views[c];
if(v && $.isArray(v)){
destroyViews(v);
} else {
v && v.destroy && v.destroy();
}
delete views[c];
}
}
}(this.views);
delete this.views;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment