所以 url 看起来像'/root/10/2'
第 2 页?
define(['backbone','models/Video'],function(Backbone,Video) {
return Videos = Backbone.Collection.extend ({
model:Video,
initialize: function(models, options){
// get options.genre or use 'rock' as default
this.genre = options && _.has(options, 'genre') ? options.genre : 'rock';
},
fetch: function(options){
// make sure we have options object
options = options ? _.clone(options) : {};
// if no url in options, create url using options.page
if(!_.has(options, 'url')){
options.url = "/" + this.genre + "/10/" + options && _.has(options, 'page') ? options.page : 1;
}
return Backbone.Collection.prototype.fetch.apply(this, [options]);
}
});
});
// fetch page 3
var rock = new Videos(null, {genre: 'rock'});
rock.on('reset', function(){
// each time you fetch, this will be called.
});
rock.fetch({page:3});