diff --git a/core/client/views/blog.js b/core/client/views/blog.js index f2a4ece298..17546c21db 100644 --- a/core/client/views/blog.js +++ b/core/client/views/blog.js @@ -35,6 +35,7 @@ initialize: function (options) { this.$('.content-list-content').scrollClass({target: '.content-list', offset: 10}); 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) 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 () { + var $list = this.$('ol'); + + // Clear out any pre-existing subviews. + this.removeSubviews(); + 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.showNext(); }