var Router = Backbone.Router.extend({ initialize: function () { var that = this; $(function () { alert('page loaded!'); Backbone.history.start({ root: '/abernier/raw/3183257/', pushState: true, hashChange: false }); // Trap links $('body').delegate('a[href]:not([href^=#])', 'click', function (e) { e.preventDefault(); that.navigate($(this).attr('href'), {trigger: true}); }); // Block anchors for hash-based history if (!Backbone.history._hasPushState) { $('body').delegate('a[href^=#]', 'click', function (e) { e.preventDefault(); }); } }); }, routes: { '': 'home', 'product1.html': 'product1' }, home: function () { $('body').html($('#home-tmpl').text()); alert('Welcome Home!'); }, product1: function () { $('body').html($('#product1-tmpl').text()); alert('Welcome to Product1!'); } }); var router = new Router();