한 페이지 스크롤링 사이트 만들기. 즉, 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);
}});
}
});
은 나의 경로입니다. 해시가 변경되면 해당 섹션으로 스크롤됩니다. 지금 페이지는 페치를 계속하고 이미 페이지에있는 내용을 계속 추가합니다.