对于主干我很陌生,并且试图添加一个“加载更多”按钮来实现项目。我希望加载按钮可以在每次点击时从我的收藏中说出六个新项目。我将如何实现?骨干收集。 “加载更多”按钮
现在我有整个集合加载时查看initziales。但我想只是加载六个项目会更好? (那些将是可见的),然后我想追加六个新的每次点击“加载更多”。
任何人都可以告诉我/帮我在这一个?
收集
define([
'Underscore',
'Backbone',
'app',
'VideoModel',
], function (_, Backbone, app, VideoModel) {
var VideoCollection = Backbone.Collection.extend({
model: VideoModel,
url: url,
parse: function (response) {
return response;
},
initialize: function() {
}
});
return VideoCollection;
});
模型
define([
'Underscore',
'Backbone',
'app',
],功能(_,骨干,应用程序){
var VideoModel = Backbone.Model.extend({
defaults: function() {
return {
data: {
id: "",
created: "",
timestamp: ""
}
};
},
clear: function() {
this.destroy();
}
});
return VideoModel;
});
查看
define([
'Underscore',
'Backbone',
'app',
'VideoCollection'
]功能(_,骨干,应用程序,VideoCollection){
var StartView = Backbone.View.extend({
tagName: "section",
id: "start",
className: "content",
events: {
},
initialize: function(){
$(".container").html(this.el);
this.template = _.template($("#start_template").html(), {});
this.collection = new VideoCollection();
this.render();
},
render: function(){
this.$el.html(this.template);
this.collection.fetch({
success: function (obj) {
var json = obj.toJSON()
for(var i=0; i<json.length; i++) {
}
}
});
},
kill: function() {
this.remove();
}
});
return StartView;
});