【发布时间】:2015-08-04 04:31:25
【问题描述】:
我在使用一个小型 dart 应用程序时遇到了问题,该应用程序在 Chrome 和 Firefox 中运行得非常好……猜猜看……在 IE 10 和 11 中没有(Win10 Preview 中的 Project Spartan 有效!)。
这是一个简单的 UI 控制逻辑,如下所示:
...
//init elements
SelectElement studyList = querySelector('#studies');
SelectElement roleList = querySelector('#roles');
SelectElement siteList = querySelector('#sites');
ButtonElement createButton = querySelector('#create');
//Kick in the UI logic
_populateStudies();
//UI logic
_populateStudies() {
for (var study in studies) {
OptionElement option = new OptionElement();
option.text = study;
studyList.children.add(option);
}
for (OptionElement element in studyList.children) {
throw new Exception("ADDING_HANDLER");
//以下执行,handler好像挂了
element.onClick.listen(_studyClickHandler);
}
}
//从此不再在IE中执行
_studyClickHandler(Event e) {
siteList.children.clear();
roleList.children.clear();
_populateRoles();
}
_populateRoles(){
List<String> roles = context.getRolesFor(studyList.selectedOptions[0].text);
for (var role in roles) {
OptionElement option = new OptionElement();
option.text = role;
roleList.children.add(option);
}
for (OptionElement element in roleList.children) {
element.onClick.listen(_roleClickHandler);
}
}
...
在 IE 中,第二个选择框保持为空。 Chrome 和 Firefox 按预期处理代码,根据在第一个选择框中选择的元素填充框的子项。 我不知道问题出在哪里...我将处理程序重构为匿名函数
onClick.listen((_){
handle stuff
});
控制台根本没有显示错误。 也许有一个简单的解决方案,但我对飞镖比较陌生,无法弄清楚?
谢谢
【问题讨论】:
-
请添加一个代码示例,其中包含我们可以在浏览器中运行的所有代码。
-
这取决于 AJAX 调用获取的数据。我将尝试对其进行一些模拟并发布一段代码......
标签: dart internet-explorer-10 internet-explorer-11 dart2js