Skip to content

Commit

Permalink
Fix #2108; be consistent with _.each iteration
Browse files Browse the repository at this point in the history
Conflicts:
	src/behaviors.js
  • Loading branch information
megawac authored and samccone committed Jan 14, 2015
1 parent 122f208 commit a53cc47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ Marionette.Behaviors = (function(Marionette, _) {
// a user to use the @ui. syntax.
behaviorEvents = Marionette.normalizeUIKeys(behaviorEvents, ui);

_.each(_.keys(behaviorEvents), function(key, j) {
var j = 0;
_.each(behaviorEvents, function(behaviour, key) {
var match = key.match(delegateEventSplitter);

// Set event name to be namespaced using the view cid,
// the behavior index, and the behavior event index
// to generate a non colliding event namespace
// http://api.jquery.com/event.namespace/
var eventName = match[1] + '.' + [this.cid, i, j, ' '].join(''),
var eventName = match[1] + '.' + [this.cid, i, j++, ' '].join(''),
selector = match[2];

var eventKey = eventName + selector;
var handler = _.isFunction(behaviorEvents[key]) ? behaviorEvents[key] : b[behaviorEvents[key]];
var handler = _.isFunction(behaviour) ? behaviour : b[behaviour];

_events[eventKey] = _.bind(handler, b);
}, this);
Expand Down
3 changes: 1 addition & 2 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ Marionette.View = Backbone.View.extend({
this.ui = {};

// bind each of the selectors
_.each(_.keys(bindings), function(key) {
var selector = bindings[key];
_.each(bindings, function(selector, key) {
this.ui[key] = this.$(selector);
}, this);
},
Expand Down

0 comments on commit a53cc47

Please sign in to comment.