开发者

Why should I bind on render event inside view Initialize?

开发者 https://www.devze.com 2023-03-07 00:47 出处:网络
I don\'t 开发者_开发知识库understand why should I bind on render inside view Initialize? example:

I don't 开发者_开发知识库understand why should I bind on render inside view Initialize?

example:

_bindAll(this, "render") ??


You do not have to, but if your render is triggered based on an event, you will want it to run within the context of your view (this). If you have something like this:

this.model.bind("change", this.render)

The change event will be run within the context of the model, but you want the render call to run against the view.

To simplify all this binding, you can use _.bindAll and list all the methods you might call from outside your views. You should know that Backbone is auto binding the callbacks used for UI events:

events: {"click" : "render"}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号