| ko.router.configure({ hashPrefix: '#/', debug: true, notify: notify, pushState: true }); |
| |
| // Configure module loader |
| ko.bindingHandlers.module.baseDir = 'js'; |
| |
| // Define the routes before ko.applyBindings() |
| ko.router.map([ |
| { route: '', name: 'home', template: 'home', title: 'Welcome', nav: true }, |
| { route: 'who-we-are', name: 'about', title: 'About Us', nav: true }, |
| { route: 'contact-us', name: 'contact', title: 'Contact Us', nav: true }, |
| { route: 'content/news/:articleId', module: 'news' } |
| //{ route: 'blog(/:slug)', name: 'blog', title: 'Crazy Blog' }, |
| //{ route: '*notfound', name: 'notfound', callback: notFoundHandler } |
| ]).mapNotFound({ callback: notFoundHandler }); // can specify a module/template/callback/title |
| |
| // Bind the view model |
| ko.applyBindings(vm); |
| |
| // Should call ko.router.init() after ko.applyBindings() when using |
| // the route bindingHandler. otherwise could safely call ko.router.init() |
| // once the routes have been defined. |
| ko.router.init(); //calls ko.history.start() behind the scenes
|