Skip to content

Commit

Permalink
No need for _.bind, just use the closure.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Mar 20, 2013
1 parent 2b8f116 commit b9ea638
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,14 @@
route: function(route, name, callback) {
if (!_.isRegExp(route)) route = this._routeToRegExp(route);
if (!callback) callback = _.isFunction(name) ? name : this[name];
Backbone.history.route(route, _.bind(function(fragment) {
var args = this._extractParameters(route, fragment);
callback && callback.apply(this, args);
this.trigger.apply(this, ['route:' + name].concat(args));
this.trigger('route', name, args);
Backbone.history.trigger('route', this, name, args);
}, this));
var router = this;
Backbone.history.route(route, function(fragment) {
var args = router._extractParameters(route, fragment);
callback && callback.apply(router, args);
router.trigger.apply(router, ['route:' + name].concat(args));
router.trigger('route', name, args);
Backbone.history.trigger('route', router, name, args);
});
return this;
},

Expand Down

0 comments on commit b9ea638

Please sign in to comment.