鉴于通过电子邮件进行进一步沟通......以及由(使用mootools核心团队的)cpojer使用filemanager mootools plugin引起的问题,我正在更新我对通过电子邮件给出的建议的回复。问题
源代码:http://github.com/cpojer/mootools-filemanager/raw/master/Source/FileManager.js - 线408是问题
为什么原来的代码可能会失败(在IE8)的原因,但我会考虑它作为不安全反正 - 是,MooTools的事件UID每元素驱动。 I.E. - 如果你注入一个元素或通过一个选择器并通过它可能创建它通过新的Element()类(tbc),它分配一个UID启用元素存储启用。原始表单中使用的链接可能会导致addEvent在元素存在之前运行,从而导致失败。这里的问题是,为什么当我进行的所有测试似乎都能正常工作时,它将无法附加事件。基本上,Asset.image码云:
var image = new Image();
var element = document.id(image) || new Element('img');
element.store("foo", "bar");
alert(element.retrieve("foo") || "failed");
这并分配一个UID,并使其可用于前甚至它是事件的DOM中的一员。 tescase:http://fragged.org/dev/ie8-new-image-bug.php - 为你输出'bar'吗?如果是这样,没有理由怀疑由于存储而导致的事件分配顺序与DOM插入的顺序有关,它可能是一个总的操作问题/ onclick问题。
无论哪种方式,你可以尝试更换与这个类的代码,аlthough我没有测试它:
var _this = this;
icons.push(new Asset.image(this.options.assetBasePath + 'disk.png', {
title: this.language.download
"class": 'browser-icon',
onload: function() {
// once the src has been set and image loaded
// inject into DOM (hence open to manilulations) and then add the event
this.inject(el, 'top').addEvent('click', function(e) {
_this.tips.hide();
e.stop();
window.open(_this.options.baseURL + _this.normalize(_this.Directory + '/' + file.name));
});
}
}));
也考虑:IE浏览器 - 在过去 - 已经知道发生问题缓存图片加载以失败告终触发事件,如果事件的分配大约是走错了路:
// wrong:
var image = new Image();
image.src = 'image.jpg';
image.onload = function() { // evil, won't work if image already cached, it won't trigger
...
};
// right:
var image = new Image();
image.onload = function() { // always fires the event.
...
};
image.src = 'image.jpg';
这只是为线索,mootools的保证插入VS事件指配的正确顺序呢 - 但不意味着IE8没有其他类似的问题要做w ith事件。
他们的工作,http://fragged.org/dev/ie8-asset-bug.php - 虽然不在ietester,出于某种原因 – 2010-05-02 09:16:47