Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Commit

Permalink
Add _removeChild method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Eastridge committed Dec 27, 2012
1 parent 8a8bec2 commit c8632c7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/thorax.js
Expand Up @@ -95,20 +95,24 @@ Thorax.View = Backbone.View.extend({
return view;
},

_removeChild: function(view) {
delete this.children[view.cid];
view.parent = null;
return view;
},

destroy: function(options) {
options = _.defaults(options || {}, {
children: true
});
this.trigger('destroyed');
delete viewsIndexedByCid[this.cid];
if (options.children) {
_.each(this.children, function(child) {
child.parent = null;
_.each(this.children, function(child) {
this._removeChild(child);
if (options.children) {
child.destroy();
});
this.children = {};
}

}
}, this);
this.freeze && this.freeze();
},

Expand Down

0 comments on commit c8632c7

Please sign in to comment.