仅重新呈现 Marionette.js CollectionView 的更改部分
Re-render only changed section of Marionette.js CollectionView
下面是我目前拥有的代码,它在每次添加或删除模型时重新呈现 collectionView。然而,它似乎效率低下,因为它每次都必须渲染整个东西,而我真正需要的只是删除一个 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.
下面是我目前拥有的代码,它在每次添加或删除模型时重新呈现 collectionView。然而,它似乎效率低下,因为它每次都必须渲染整个东西,而我真正需要的只是删除一个 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.