Spine Zombie Prevention

Note: we use backbone 1.0.0

I'm relatively new to Backbone and am going through some of the code written by a former employee. Instead of copying the insert blindly, I wanted to understand how he did it, and that when I started to wonder how best to handle zombie looks.

var view = new editItemView({ model: this.model });
    this.ui.editItemPopup.html(view.render().el).modal({ modalOverflow: true });

This creates an instance of the view and pulls it in modal mode. The model has buttons "Save Changes", "Undo" and "Delete". We will look at the clean work done with saving changes and deleting.

onDelete: function() {
    this.stopListening(this.model);
    this.$el.parent().modal('hide');
    this.$el.remove();
},
onApplyChangesClick: function () {
    this.stopListening(this.model);
    this.close();
},
close: function () {
    this.$el.parent().modal('hide');
}

As far as I can tell, this code will not drop the view. And if I added another listener to the above view

this.listenTo(this.model.AnotherItem, 'change', this.doSomething);

.model.AnotherItem, this.do- . ?

- . http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/

,

 onDelete: function() {
    this.close()
},
onApplyChangesClick: function () {
    this.close();
},
close: function () {
    this.$el.parent().modal('hide');
    this.remove();
}

his.remove() stopListening dom ( , . $el.remove)

, , this.unbind()

this.unbind() will unbind any events that our view triggers directly – that is, anytime we may have called this.trigger(...) ` , .

Backbone 1.0.0 ( )? 3 , , view.unbind . , unbind off.

this.remove();
this.off();
+4
1

, : - . - , , , . , , , . , , , 20x100, View.

, - , , , Javascript. , : , " ", , , " " - , - .

, , . Backbone , , Backbone.View (.. , events View). , View , ...

... , , , , jQuery. , , View , : . , , View -.

+4

All Articles