2
後,我有一個MooTools的類,使用XHR上傳文件:全球範圍 - 訪問「這個」射擊事件偵聽器
var foo = new Class({
initialize: function() {
this.bar = 'value';
},
upload: function() {
// This method uploads a file
….
xhr.addEventListener('load', this.uploadComplete, false);
….
},
uploadComplete: function() {
// Is getting called on completion of file upload
console.log(this.bar); // undefined, but I want to to be 'value'
}
});
我想訪問this.bar
在uploadComplete
方法,但this
是沒有得到穿過在xhr.addEventListener('load', this.uploadComplete, false);
任何幫助表示讚賞。