Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add _removeChild method

  • Loading branch information...
commit c8632c7356c7b75e95272879413d2ab23c0337b9 1 parent 8a8bec2
Ryan Eastridge authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 src/thorax.js
View
18 src/thorax.js
@@ -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();
},
Please sign in to comment.
Something went wrong with that request. Please try again.