【发布时间】:2012-12-07 00:57:52
【问题描述】:
这里有一个关于 Jquery 的类似问题: Asynchronously load images with jQuery
接受的answer 非常聪明并且效果很好(对于Jquery):
var img = $("<img />").attr('src', 'http://somedomain.com/image.jpg')
.load(function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
alert('broken image!');
} else {
$("#something").append(img);
}
});
我的问题是,在 Dojo 中与此等效的规范是什么(包括错误处理)?
【问题讨论】: