var SiteRouter = Router.extend({ el: 'body', routeByHash: true, routes: { '/': 'intro', '/intro': 'intro', '/hub': 'hub', '/story': 'story', '/archive': 'archive', '/store': 'collection', '/store/:code': 'product', '/account/login': 'login', '/account/logout': 'logout', '/account/signup': 'signup', '/account/profile': 'profile', '/account/payment': 'payment', '/account/shipping': 'shipping', '/faq': 'faq', '/search': 'search', '/cart': 'cart', }, initialize: function(){ var fn for (var route in this.routes) { fn = this.routes[route] if (! this.hasOwnProperty(fn)) { this[fn] = this.default_view(fn) } } }, go: function(url){ if (app.view && app.view.hide) { app.view.hide() } window.location.href = "#/" + url this.parseRoute(url) }, default_view: function(name){ var fn = function(){ console.log(name) app.view = app[name] app[name].show() }.bind(this) return fn }, product: function(code){ app.view = app.product app.product.load(code) app.product.show() }, })