0
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绑定
为什么额外的功能封装在那里? this.ajax.onload = function(){me.onload.apply(me,[null]);} – Joshua 2010-05-09 03:15:52
@ Joshua:你是对的,那是不必要的,它甚至没有它。 – Pablo 2010-05-09 03:18:05