public
Created

Backbone.Router and pushState

  • Download Gist
router.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
define( [
"jquery",
"underscore",
"backbone",
"models/home",
"views/home",
"models/item",
"views/item"
], function( $, _, Backbone, HomeModel, HomeView, ItemModel, ItemView ){
var Router = Backbone.Router.extend({
routes:{
"": "home",
"/item": "item"
},
initialize: function(){
_.bindAll( this, "home", "item" );
},
home: function(){
var homeModel = new HomeModel();
new HomeView({
model: homeModel
});
homeModel.fetch();
},
item: function(){
var itemModel = new ItemModel();
new ItemView({
model: itemModel
});
itemModel.fetch();
}
});
 
return Router;
 
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.