Backbone routines and events

I work with Backbone in a few days, looking at the design templates and what you have. Today I fiddled with sub-views, read a bunch of resources. First of all, these 2 posts are

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

Jan Storm Taylor
http://ianstormtaylor.com/assigning-backbone-subviews -made-even-cleaner /

These and others were very useful in helping me set up some subspecies and handle their closure in what I think is right:

Backbone.View.prototype.close = function(){
    var ctx = this;
    _.each(ctx.subViews(), function(view) {
        view.close();
    });
    this.remove();
    this.unbind();
}

There are no problems, it seems that I expected. But I wanted to check it out, just to find out what happened. So I stopped calling subViews and stuck with my render about 20,000 times:

Backbone.View.prototype.close = function(){
    var ctx = this;
    _.each(ctx.subViews(), function(view) {
        //view.close();
    });
    this.remove();
    this.unbind();
}

DOM. - jQuery , , - . , , , jQuery . :

Backbone.View.prototype.close = function(){
    var ctx = this;
    _.each(ctx.subViews(), function(view) {
        //view.close();
    });
    this.remove();
    //this.unbind();
}

Chrome - .

, :

"" , ? - ? , $el?

+5
1

DOM, jQuery DOM, . unbind() Backbone Events.off, , , myChildView.on('someEvent', ...). , , . , this.unbind() this.off().

, Backbone.Events( 0.9.9) listenTo() stopListening(), this.stopListening() close(). , - this.listenTo(this.model, ...), .

+3

All Articles