【发布时间】:2010-05-09 03:02:27
【问题描述】:
MyObj =
{
ajax: null,
init: function()
{
this.ajax = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
this.ajax.onload = function()
{
return function() {this.onload.apply(this, [null]);}
};
},
onload: function ()
{
Reader.log("I really hope I can use `this.ajax` here");
}
}
将 onload 绑定到 MyObj 不是正确的方法吗?由于某种原因,onload 从未调用过。但是,如果我避免绑定并只输入this.ajax.onload = this.onload,则调用onload。如何进行绑定工作?
【问题讨论】:
标签: javascript binding