dijit / form /使用Esri Javascript 3.7在Internet Explorer中选择已损坏

时间:2013-10-22 17:29:13

标签: javascript dojo arcgis esri arcgis-js-api

在Firefox中开发Web地图应用程序后,我在Internet Explorer(公司标准)中测试了我的代码,发现dijit / form / Select使用最新的Esri JavaScript v3.7行为不端。

我看到的问题是,当使用v3.7时,Select不会更新/更改列表中的第一个选项。如果我将版本降低到3.6,它会按预期工作。

我尝试过7到10的IE浏览器模式,并且在所有这些模式之间遇到了相同的行为。有人可以证实他们正在经历同样的事情吗?

3.7中的示例 - http://jsbin.com/aVIsApO/1/edit

3.6中的示例 - http://jsbin.com/odIxETu/7/edit

码块

    var url = "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/Street_Trees/FeatureServer/0";
var frmTrees;
require([
    "esri/tasks/query",
    "esri/tasks/QueryTask",
    "dojo/dom-construct",
    "dijit/form/Select",
    "dojo/parser",
    "dijit/registry",
    "dojo/on", 
    "dojo/ready",
    "dojo/_base/connect",
    "dojo/domReady!"
], function(
   Query,
    QueryTask,
    domConstruct, 
    Select,
    parser,
    registry,
    on,
    ready,
    connect
) { 

    ready(function() {

        frmTrees = registry.byId("trees");

        var qt = new QueryTask(url);
        var query = new Query();
        query.where = "FID < 25";
        query.orderByFields = ["qSpecies"];
        query.returnGeometry = false;
        query.outFields = ["qSpecies", "TreeID"];
        query.groupByFieldsForStatistics = ["qSpecies"];
        //query.returnDistinctValues = true;
        qt.execute(query, function(results) {
            //var frm_domain_area = dom.byId("domain_area");
            var testVals = {};

            for (var i = 0; i < results.features.length; i++) {
                var id = results.features[i].attributes.TreeID;
                var desc = results.features[i].attributes.qSpecies;
                if (!testVals[id]) {
                    testVals[id] = true;
                    var selectElem = domConstruct.create("option",{ label: desc + " (" + id + ")", value: id });
                    frmTrees.addOption(selectElem);
                }
            }
        });

        frmTrees.on("change", function() {
            console.debug(frmTrees.get("value"));
        });
    });

});    

1 个答案:

答案 0 :(得分:1)

不是创建DOM元素并将其传递给dijit / form / Select.addOption,而是传递一个带有label和value属性的简单对象:

qt.execute(query, function(results) {
    //var frm_domain_area = dom.byId("domain_area");
    var testVals = {};

    for (var i = 0; i < results.features.length; i++) {
        var id = results.features[i].attributes.TreeID;
        var desc = results.features[i].attributes.qSpecies;
        if (!testVals.hasOwnProperty(id)) {
            testVals[id] = true;
            var label = desc + " (" + id + ")";
            frmTrees.addOption({label: label, value: id});
        }
    }
});

工作示例(本地复制,这适用于IE8,但不适用于jsbin上的IE8):http://jsbin.com/eKULIgu/1/edit