При выполнении следующего кода Collection View не полностью удаляется. currentView.remove();
и currentView.unbind();
не снимает & вскрыть все изображения в изображениях модели. Что мне нужно сделать, чтобы удалить просмотр коллекции + модель? (Сброс не вариант)Ошибка утечки памяти.
var Coll_Item = .. //contains collection within models
var currentView = new DiagnoseApp.Views.Coll_Item({collection: Coll_Item});
currentView.remove();
currentView.unbind();
(я взял кучного снимки с Google-хром и всякий раз, когда код выполняется куча растет.)
Коллекция Вид:
DiagnoseApp.Views.Coll_Item = Backbone.View.extend({
initialize: function(){
this.collection;
},
render: function(){
this.addAll();
},
addAll: function(){
this.$el.html($('<table id="whatever" />'));
this.collection.each(this.addOne, this);
},
addOne: function(Param){
var tbodyView = new DiagnoseApp.Views.item({model: Param});
this.$el.find('#whatever').append(tbodyView.el);
}
});
Model View :
DiagnoseApp.Views.item = Backbone.View.extend({
newTemplate: _.template($('#item-template1').html()),
initialize: function() {
this.render();
this.model.on('change', this.render, this);
},
render: function() {
this.$el.html(this.newTemplate(this.model.toJSON()));
},
events: {
'blur .edit' : 'editParam',
'keypress .edit' : 'updateOnEnter'
},
updateOnEnter: function (e){
if (e.which == 13){
this.editParam();
}
},
editParam: function(){
var newValue = this.input.val().trim();
this.model.set('val', newValue);
}
});
'this.listenTo (this.model, 'change', this.render);' –