mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Merge pull request #1258 from gotdibbs/Issue1242
Fix duplication of entries in infinite scroll
This commit is contained in:
commit
11da233015
1 changed files with 11 additions and 1 deletions
|
@ -35,6 +35,7 @@
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
this.$('.content-list-content').scrollClass({target: '.content-list', offset: 10});
|
this.$('.content-list-content').scrollClass({target: '.content-list', offset: 10});
|
||||||
this.listenTo(this.collection, 'remove', this.showNext);
|
this.listenTo(this.collection, 'remove', this.showNext);
|
||||||
|
this.listenTo(this.collection, 'add', this.renderPost);
|
||||||
// Can't use backbone event bind (see: http://stackoverflow.com/questions/13480843/backbone-scroll-event-not-firing)
|
// Can't use backbone event bind (see: http://stackoverflow.com/questions/13480843/backbone-scroll-event-not-firing)
|
||||||
this.$('.content-list-content').scroll($.proxy(this.checkScroll, this));
|
this.$('.content-list-content').scroll($.proxy(this.checkScroll, this));
|
||||||
},
|
},
|
||||||
|
@ -102,9 +103,18 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderPost: function (model) {
|
||||||
|
this.$('ol').append(this.addSubview(new ContentItem({model: model})).render().el);
|
||||||
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
var $list = this.$('ol');
|
||||||
|
|
||||||
|
// Clear out any pre-existing subviews.
|
||||||
|
this.removeSubviews();
|
||||||
|
|
||||||
this.collection.each(function (model) {
|
this.collection.each(function (model) {
|
||||||
this.$('ol').append(this.addSubview(new ContentItem({model: model})).render().el);
|
$list.append(this.addSubview(new ContentItem({model: model})).render().el);
|
||||||
}, this);
|
}, this);
|
||||||
this.showNext();
|
this.showNext();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue