【发布时间】:2015-03-05 05:19:02
【问题描述】:
我的所有视图都附加了一个关闭函数,
Backbone.View.prototype.close = function()
{
this.remove();
this.unbind();
if (this.closeMe) this.closeMe();
};
在视图内部的 closeMe() 函数中,我调用了主干的 off() 函数,以从模型和集合中删除先前绑定的回调函数。
closeMe: function()
{
if(this.model)
this.model.off(null, null, this);
...
}
问题是,如果我在初始化函数中有一些变量附加到当前视图,我需要通过 closeMe() 函数来处理它们吗?
initialize : function(options)
{
...
this.myVar= options.something;
}
【问题讨论】:
标签: javascript backbone.js memory-management