Created
April 26, 2013 22:11
-
-
Save leonardorb/5470797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thorax.Router = Backbone.Router.extend({ | |
constructor: function() { | |
var response = Thorax.Router.__super__.constructor.apply(this, arguments); | |
initializeRouter.call(this); | |
return response; | |
}, | |
route: function(route, name, callback) { | |
if (!callback) { | |
callback = this[name]; | |
} | |
//add a route:before event that is fired before the callback is called | |
return Backbone.Router.prototype.route.call(this, route, name, function() { | |
this.trigger.apply(this, ['route:before', route, name].concat(Array.prototype.slice.call(arguments))); | |
return callback.apply(this, arguments); | |
}); | |
} | |
}); | |
Thorax.Routers = {}; | |
createRegistryWrapper(Thorax.Router, Thorax.Routers); | |
function onRoute(router /* , name */) { | |
if (this === router) { | |
this.trigger.apply(this, ['route'].concat(Array.prototype.slice.call(arguments, 1))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment