Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor: Initialize CompositeView#bindings in constructor

  • Loading branch information...
commit ea5ea57ce880410d0fc2ef7f6f951b13c68b4870 1 parent 43d3fe9
Jason Morrison jasonm authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/assets/javascripts/backbone-support/composite_view.js
6 lib/assets/javascripts/backbone-support/composite_view.js
View
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.