I suspect that the way views are handled in backbone.js is wrong in such a way that it creates a "memory leak".
There is a representation that is constantly being rewritten by another copy. The new copy is associated with another model.
I create and add a view to it as a parent view by setting a parameter elwhen creating a child view.
The strange thing that happens is that even if the new view is rendered on top of the old view, when I click the button button, a pop-up warning appears for every child that was displayed every time, although the button was listened, they should go away, they answer the new button.
I took advantage of a quick fix by calling a function on the old view to stop listening to events until a new view was added. But , that this problem exists at all, tells me that all old views hang around and will slow down the application over time if the user does not refresh the page often enough.
var parent = new (Backbone.Marionette.ItemView.extend({
ui:{
child_container: '#child-container'
},
onRender: function(){
...
}
on_Outside_Event: function(new_model){
this.child_view.destroy_view();
this.child_view = childView({
el: this.ui.child_container,
model: new_model
})
this.child_view.render();
}
}))();
var childView = Backbone.Marionette.ItemView.extend({
events:{
'click button': 'on_click_button'
},
on_click_button: function(){
alert('Button clicked');
},
destroy_view: function(){
this.undelegateEvents();
}
})
, , . - . - , , .
" ", , , , : events:{ 'click #cancel-button': 'on_button_click'}
, , , , , .

?
, ?
, , removeData().unbind(); remove() this.$el, , , , el, (el: this.ui.child_container)
var childView = Backbone.Marionette.ItemView.extend({
...
destroy_view: function(){
this.undelegateEvents();
this.$el.children().removeData().unbind();
this.$el.children().remove();
}