Permalink
Browse files

Refactor: Initialize CompositeView#bindings in constructor

  • Loading branch information...
1 parent 43d3fe9 commit ea5ea57ce880410d0fc2ef7f6f951b13c68b4870 @jasonm jasonm committed Sep 28, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/assets/javascripts/backbone-support/composite_view.js
@@ -1,5 +1,6 @@
Support.CompositeView = function(options) {
this.children = _([]);
+ this.bindings = _([]);
Backbone.View.apply(this, [options]);
};
@@ -14,15 +15,14 @@ _.extend(Support.CompositeView.prototype, Backbone.View.prototype, {
bindTo: function(source, event, callback) {
source.bind(event, callback, this);
- this.bindings = this.bindings || [];
this.bindings.push({ source: source, event: event, callback: callback });
},
unbindFromAll: function() {
- _.each(this.bindings, function(binding) {
+ this.bindings.each(function(binding) {
binding.source.unbind(binding.event, binding.callback);
});
- this.bindings = [];
+ this.bindings = _([]);
},
renderChild: function(view) {

0 comments on commit ea5ea57

Please sign in to comment.