私はこのようなクラスを持っています
var grid = function () {
this.cell = null;
this.loadImage = function () {
var image = new Image();
var object = this;
image.src = "blah";
$(image).load(function () {
object.cell = this;
});
}
this.showImage = function () {
alert(object.cell); // This should print [object Object] ... but it print null;
}
}
showImage関数は、loadImage関数から読み込まれた呼び出された画像の後に呼び出されます。object.cellがnullである理由を誰かが知っていますか...loadImageでこのオブジェクトへの参照があります。