/** * Router for track browser. */ var TrackBrowserRouter = Backbone.Router.extend({ initialize: function(options) { this.view = options.view; // Can't put regular expression in routes dictionary. // NOTE: parentheses are used to denote parameters returned to callback. this.route(/([\w]+)$/, 'change_location'); this.route(/([\w]+\:[\d,]+-[\d,]+)$/, 'change_location'); // Handle navigate events from view. var self = this; self.view.on("navigate", function(new_loc) { self.navigate(new_loc); }); }, change_location: function(new_loc) { this.view.go_to(new_loc); } });