ESRI编辑器小部件抛出JavaScript运行时错误:无法获取属性' preventDefault'未定义或空引用

时间:2014-04-23 16:09:45

标签: javascript dojo arcgis-js-api

我正在使用JS API 3.5。

我的网络应用中有一个编辑器小部件。当我在窗口小部件中单击New Selection时,它会抛出错误'Uncaught TypeError:无法读取属性'preventDefault'未定义'

在Chrome和Firefox中,即使控制台日志出现此错误,我也可以绘制并继续,但IE 11会在此异常中断。

确切的错误消息是 第34行第381861行http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/

中未处理的异常

0x800a138f - JavaScript运行时错误:无法获取未定义或空引用的属性'preventDefault'

在IE调试文件中,代码看起来像e的值未定义。

_onClick:function(e){
        var ok=this.inherited(arguments);
        if(ok)
        {
           if(this.valueNode)           
        {           
          this.valueNode.click();
          e.preventDefault(); //e is undefined
          e.stopPropagation();}
        }
           return ok;
        }

我对如何处理此异常没有任何线索,因为我无法在源代码中找到它。

下面是创建编辑器小部件的代码:

          require(["esri/dijit/editing/Editor",
                "esri/dijit/editing/TemplatePicker",
                 "dojo/domReady!"], lang.hitch(this, function (Editor, TemplatePicker) {

          console.log("click on new Editor => " + ops);
          this.editor = new Editor({
            'settings': ops
          }, editorContainer);
          this.editor.startup();
        }));

我没试过以下事情: - 包括“dojo / domReady!”在调用编辑器小部件之前 - 改变了

请帮忙!

以下是调用onClick编辑器小部件的代码:

   define([
     'dojo/_base/declare',
     'dijit/_WidgetBase',
     'dijit/_TemplatedMixin',
     'dijit/_WidgetsInTemplateMixin',
      'dojo/_base/lang',
      'dojo/dom-construct',
         'dojo/domReady!'], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, domConstruct) {

  return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
      templateString: '<div class="gis_GeoLocation_Dijit"><div style="text-align:center;"><button data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:toggleEditing" data-dojo-props="label:\'Start Editing\',baseClass:\'geoLocationButton\'" style="background-color:#ECECEC;" data-dojo-attach-point="toggleBTN"></button></div><div style="margin-top:5px;" data-dojo-attach-point="containerNode"></div></div>',
    widgetsInTemplate: true,
    editor: null,
    isEdit: false,
    templatePicker: null,

    toggleEditing: function () {
      if (!this.isEdit) {
        var ops = lang.clone(this.settings);
        ops.map = this.map;
        ops.layerInfos = this.layerInfos;

        var templatePickerOptions = this.templatePickerOptions;
        templatePickerOptions.featureLayers = this.templatePickerFeatureLayers;

        // create container for Editor
        var editorContainer = domConstruct.create("div", {
          innerHTML: '<img style="display:inline;" src="data:image/gif;base64,R0lGODlhIAAgALMAAP///7Ozs/v7+9bW1uHh4fLy8rq6uoGBgTQ0NAEBARsbG8TExJeXl/39/VRUVAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBQAAACwAAAAAIAAgAAAE5xDISSlLrOrNp0pKNRCdFhxVolJLEJQUoSgOpSYT4RowNSsvyW1icA16k8MMMRkCBjskBTFDAZyuAEkqCfxIQ2hgQRFvAQEEIjNxVDW6XNE4YagRjuBCwe60smQUDnd4Rz1ZAQZnFAGDd0hihh12CEE9kjAEVlycXIg7BAsMB6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YEvpJivxNaGmLHT0VnOgGYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHQjYKhKP1oZmADdEAAAh+QQFBQAAACwAAAAAGAAXAAAEchDISasKNeuJFKoHs4mUYlJIkmjIV54Soypsa0wmLSnqoTEtBw52mG0AjhYpBxioEqRNy8V0qFzNw+GGwlJki4lBqx1IBgjMkRIghwjrzcDti2/Gh7D9qN774wQGAYOEfwCChIV/gYmDho+QkZKTR3p7EQAh+QQFBQAAACwBAAAAHQAOAAAEchDISWdANesNHHJZwE2DUSEo5SjKKB2HOKGYFLD1CB/DnEoIlkti2PlyuKGEATMBaAACSyGbEDYD4zN1YIEmh0SCQQgYehNmTNNaKsQJXmBuuEYPi9ECAU/UFnNzeUp9VBQEBoFOLmFxWHNoQw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AIfkEBQUAAAAsAAAPABkAEQAABGeQqUQruDjrW3vaYCZ5X2ie6EkcKaooTAsi7ytnTq046BBsNcTvItz4AotMwKZBIC6H6CVAJaCcT0CUBTgaTg5nTCu9GKiDEMPJg5YBBOpwlnVzLwtqyKnZagZWahoMB2M3GgsHSRsRACH5BAUFAAAALAEACAARABgAAARcMKR0gL34npkUyyCAcAmyhBijkGi2UW02VHFt33iu7yiDIDaD4/erEYGDlu/nuBAOJ9Dvc2EcDgFAYIuaXS3bbOh6MIC5IAP5Eh5fk2exC4tpgwZyiyFgvhEMBBEAIfkEBQUAAAAsAAACAA4AHQAABHMQyAnYoViSlFDGXBJ808Ep5KRwV8qEg+pRCOeoioKMwJK0Ekcu54h9AoghKgXIMZgAApQZcCCu2Ax2O6NUud2pmJcyHA4L0uDM/ljYDCnGfGakJQE5YH0wUBYBAUYfBIFkHwaBgxkDgX5lgXpHAXcpBIsRADs="/>',
          "style": "text-align:center;"
        }, this.containerNode, "only");

        require(["esri/dijit/editing/Editor",
                "esri/dijit/editing/TemplatePicker",
                 "dojo/domReady!"], lang.hitch(this, function (Editor, TemplatePicker) {

          //if (templatePickerOptions != null) {
          //  console.log("new TemplatePicker => " + templatePickerOptions);
          //  this.templatePicker = new TemplatePicker(templatePickerOptions, templatePickerContainer);
          //  this.templatePicker.startup();
          //  ops.templatePicker = this.templatePicker;
          //}

          console.log("click on new Editor => " + ops);
          this.editor = new Editor({
            'settings': ops
          }, editorContainer);
          this.editor.startup();
        }));

        this.map.enableSnapping({
         tolerance: 20,
          snapKey: dojo.keys.ALT
        });

        this.toggleBTN.set('label', 'Stop Editing');
        this.isEdit = true;
      } else {
        this.editor.destroyRecursive();
        this.toggleBTN.set('label', 'Start Editing');
        this.isEdit = false;
        this.editor = null;
        this.templatePicker = null;
      }
    }
  });
});

0 个答案:

没有答案