Permalink
Browse files

build v0.11.0 pre-release

  • Loading branch information...
1 parent 722e79c commit 4027d50d281bf824fe61ed10a3db09444be423d3 @derickbailey derickbailey committed Oct 6, 2012
@@ -18,7 +18,7 @@
}
}(this, function ($, _, Backbone) {
- Backbone.Marionette = (function(Backbone, _, $){
+ Backbone.Marionette = Marionette = (function(Backbone, _, $){
var Marionette = {};
// Trigger an event and a corresponding method name. Examples:
@@ -61,8 +61,8 @@
Marionette.View = Backbone.View.extend({
constructor: function(){
- var eventBinder = new Marionette.EventBinder();
- _.extend(this, eventBinder);
+ _.bindAll(this, "render");
+ this._configureEventBinder();
Backbone.View.prototype.constructor.apply(this, arguments);
@@ -76,6 +76,20 @@
// methods if the method exists
triggerMethod: Marionette.triggerMethod,
+ // Internal method. Add the EventBinder methods to the view directly,
+ // but keep them bound to the EventBinder instance so they work properly.
+ // This allows the event binder's implementation to vary independently
+ // of it being attached to the view... for example the internal structure
+ // used to store the events can change without worry about it interfering
+ // with Marionette's views.
+ _configureEventBinder: function(){
+ var eventBinder = new Marionette.EventBinder();
+ this.eventBinder = eventBinder;
+ this.bindTo = _.bind(eventBinder.bindTo, eventBinder);
+ this.unbindFrom = _.bind(eventBinder.unbindFrom, eventBinder);
+ this.unbindAll = _.bind(eventBinder.unbindAll, eventBinder);
+ },
+
// Get the template for this view
// instance. You can set a `template` attribute in the view
// definition or pass a `template: "whatever"` parameter in

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -2,7 +2,7 @@
// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
// http://github.com/marionettejs/backbone.marionette
-Backbone.Marionette = (function(Backbone, _, $){
+Backbone.Marionette = Marionette = (function(Backbone, _, $){
var Marionette = {};
// Trigger an event and a corresponding method name. Examples:
@@ -45,8 +45,8 @@ Marionette.EventBinder = Backbone.EventBinder;
Marionette.View = Backbone.View.extend({
constructor: function(){
- var eventBinder = new Marionette.EventBinder();
- _.extend(this, eventBinder);
+ _.bindAll(this, "render");
+ this._configureEventBinder();
Backbone.View.prototype.constructor.apply(this, arguments);
@@ -60,6 +60,20 @@ Marionette.View = Backbone.View.extend({
// methods if the method exists
triggerMethod: Marionette.triggerMethod,
+ // Internal method. Add the EventBinder methods to the view directly,
+ // but keep them bound to the EventBinder instance so they work properly.
+ // This allows the event binder's implementation to vary independently
+ // of it being attached to the view... for example the internal structure
+ // used to store the events can change without worry about it interfering
+ // with Marionette's views.
+ _configureEventBinder: function(){
+ var eventBinder = new Marionette.EventBinder();
+ this.eventBinder = eventBinder;
+ this.bindTo = _.bind(eventBinder.bindTo, eventBinder);
+ this.unbindFrom = _.bind(eventBinder.unbindFrom, eventBinder);
+ this.unbindAll = _.bind(eventBinder.unbindAll, eventBinder);
+ },
+
// Get the template for this view
// instance. You can set a `template` attribute in the view
// definition or pass a `template: "whatever"` parameter in
Oops, something went wrong.

0 comments on commit 4027d50

Please sign in to comment.