Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use a FeatureLayer created from the featureCollection. I also use esri.dijit.editing.Editor to add a feature to the map. Every time feature has been added to this layer I want to send it to my remote service using rest API. I tried to use FeatureLayer's onEditsComplete event:

<!doctype html>
    <link rel="stylesheet" type="text/css" href="">
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" language="Javascript">
      var map;
      var startExtent = new esri.geometry.Extent({"xmin":-12505511,"ymin":2230016,"xmax":-3699965,"ymax":8100380,"spatialReference":{"wkid":102100}});
      var featureLayer;

      function init() {
        map = new esri.Map("mapDiv",{ extent: startExtent });
        //create and add new layer
        var layer = new esri.layers.ArcGISTiledMapServiceLayer("");

        var jsonFS = {
          "displayFieldName": "Name",
          "fieldAliases": {
              "Name": "Name"
          "geometryType": "esriGeometryPoint",
          "spatialReference": {
              "wkid": 102100 //WGS_1984_Web_Mercator_Auxiliary_Sphere
          "fields": [{
              "name": "Name",
              "type": "esriFieldTypeOID",
              "alias": "Name"
          "features": [{
              "attributes": {
                "OBJECTID": "1",
                "Name": "1"
              "geometry": {
                  "x": -8919439.31450887,
                  "y": 4928270.761925456
              "attributes": {
                "OBJECTID": "2",
                "Name": "2"
              "geometry": {
                  "x": -8155495.379532158,
                  "y": 5075380.311392084
        var fs = new esri.tasks.FeatureSet(jsonFS);

        var featureCollection = {
          layerDefinition: {
            "geometryType": "esriGeometryPoint",
            "fields": [
                "name": "OBJECTID",
                "type": "esriFieldTypeOID",
                "alias": "OBJECTID"
              "name": "Name",
              "type": "esriFieldTypeString",
              "alias": "Name"
          featureSet: fs

        featureLayer = new esri.layers.FeatureLayer(featureCollection, {
          mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,

      function initEditor() {
        if (featureLayer === 'undefined' || featureLayer === null)
        { return; }

        var templatePicker = new esri.dijit.editing.TemplatePicker({
          featureLayers: [featureLayer],
          rows: 'auto',
          columns: 1

        var layerInfos = [{
          'featureLayer': featureLayer,

        var settings = {
          map: map,
          templatePicker: templatePicker,
          layerInfos: layerInfos

        var params = {settings: settings};

        var editorWidget = new esri.dijit.editing.Editor(params);


        dojo.connect(featureLayer, "onEditsComplete", function(edits, updates, deletes) {
            var a = 5;
            //there I want to send request to the service
            //var xhrArgs = {
            //  url: "http://XXXX/add",
            //  handleAs: "json",
            //  preventCache: true,
            //  content: {
            //      geometry: "....",
            //      text: "...."
            //  }

  <body class="claro">
    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
    <div id="editorDiv"></div>
    <button dojoType="dijit.form.Button" onclick="initEditor();">
        Set up editor

But it fires before user has entered information in the dialog created when user clicks on the map. So it seems useless. I tried onAddAttachmentComplete event but it never fires. Do you know how to specify that mentioned action shall be done after user entered text in the editor's dialog?

share|improve this question
Can you provide some more context on how this all works? What is the dialog you're using? Are you using the editor widget? A more complete code sample or even entire html page would be helpful. – Derek Swingley May 4 '11 at 15:48
up vote 4 down vote accepted

It's quiet late, but esri implemented the "graphic-add" event for featureLayers in the API v3.5.
This should finally solve your problem, without workarounds.

See here for further information.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.