Pergunta

After developing a web map app in Firefox, I tested my code in Internet Explorer (company standard) to discover that the dijit/form/Select is misbehaving using the latest Esri JavaScript v3.7.

The issue I am seeing is that the Select will not update/change from the first option in the list when using v3.7. If I bump the version down to 3.6, it works as expected.

I've tried IE browser modes from 7 to 10 and am experiencing the same behavior between all of them. Can someone confirm they are experiencing the same thing?

Example in 3.7 - http://jsbin.com/aVIsApO/1/edit

Example in 3.6 - http://jsbin.com/odIxETu/7/edit

Codeblock

    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"));
        });
    });

});    
Foi útil?

Solução

Instead of creating a DOM element and passing that to dijit/form/Select.addOption, pass a simple object with label and value properties:

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});
        }
    }
});

Working example (copy locally, this works in IE8 but not in IE8 on jsbin): http://jsbin.com/eKULIgu/1/edit

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top