遅延関数の呼び出しを実装しようとしてdone
いますが、それを行う方法が見つかりません:
jQuery.fn.imageload=function(src) {
$this=$(this);
var img=new Image();
img.src=src;
if (img.complete) {done();return;}
img.onload=done;
function done() {
console.log('done');
$this.empty().append(img);
}
return $this;
}
$('div').imageload('http://placehold.it/350x150').done(function() {
//this not called
console.log('done loading');
});
http://jsfiddle.net/oceog/m4jvd/
.done()
画像が読み込まれた後に呼び出すには、プラグイン宣言に何を追加すればよいですか?