我创建一个单页滚动网站。这意味着来自json的所有数据立即被加载,并且每次散列更改时都不需要多次获取数据。backbone.js抓取页面一次
var AppRouter = Backbone.Router.extend({
routes: {
"" : "index",
":page" : "page"
},
index: function() {
console.log('list');
this.init = new WH.ExperienceCollection();
this.book = new WH.ExperienceBook({model: this.init});
this.init.fetch();
},
page: function(page) {
this.init = new WH.ExperienceCollection();
this.book = new WH.ExperienceBook({model: this.init});
this.init.fetch({success: function(data){
WH.utils.resize();
$('html,body').stop(true, true).animate({scrollTop: $('#'+page).offset().top}, 500);
}});
}
});
是我的路线。当哈希值变化时,我希望它向下滚动到该部分。现在,该页面不断提取并添加页面上已有的内容。