javascript-仅重新渲染Marionette.js CollectionView的更改部分
作者:互联网
下面是我当前拥有的代码,这些代码在每次添加或删除模型时都会重新呈现collectionView.但是,这似乎效率低下,因为每次我真正需要的只是删除一个modelView或添加一个modelView时,都必须渲染整个事物.那么我该如何实现呢?
var CollectionView = Marionette.CollectionView.extend({
childView: ModelView,
initialize: function() {
[ "add", "remove" ].forEach(function(eventName) {
this.listenTo(this.collection, eventName, this.render, this);
}.bind(this));
}
});
在此先感谢您提供的任何帮助!
解决方法:
这已经完成了automatically in Marionette:
When a model is added to the collection, the collection view will
render that one model in to the collection of item views.When a model is removed from a collection (or destroyed / deleted),
the collection view will close and remove that model’s item view.
标签:backbone-js,marionette,javascript 来源: https://codeday.me/bug/20191119/2032322.html