Backbone.Marionette and Backbone.Paginator. CompositeView rerendering -
i'm working on infinite pagination (http://addyosmani.github.io/backbone.paginator/examples/infinite-paging/index.html)
i'm using compositeview pagination view.
and i've got following problem. each time after new portions of data paginator's collection removes old data , adds new makes compositeview rerender , erase old results.
how can resolve problem? i'm thinking disabling rerender functionality how should done properly?
thanks in advance!
var basefeedchronocompositeview = backbone.marionette.compositeview.extend({ tagname: "div", template: _.template(chronofeedcomposite_html), itemview: article, events: { 'click #loadmore-button-manual': function (e) { e.preventdefault(); this.collection.requestnextpage(); }, appendhtml: function (collectionview, itemview, index) { collectionview.$("#chronofeed-content").append(itemview.$el); } });
here basic code. this.collection.requestnextpage() - sends request data server. after gets data this.collection removes old models , adds new models.
composite view listening these events , removes itemviews old models , append itemviews new models.
and need compositeview not remove old itemviews.
im not quite sure how paginator works, i've never used it. think easiest way fix make sure collection doesnt remove old models. assume when data being returned doing set
on collection. if @ backbone docs can see can disable method removing models http://backbonejs.org/#collection-set
if you'd customize behavior, can disable options: {add: false}, {remove: false}, or {merge: false}.
so when updating collection, instead of calling
mycollection.set([o1,o2,o3]);
you should doing
mycollection.set([o1,o2,o3], {remove:false});
Comments
Post a Comment