Listen for on-create feature event

4229
3
Jump to solution
02-09-2015 09:02 AM
RiverTaig1
Occasional Contributor

I'm trying to figure out how to listen for the on-create feature event.  I'm working with the Editor widget, but it doesn't seem to expose any events. Now the attribute editor (which I can get from the editor using the code below) does expose events, but sadly not the one I'm looking for.  The following code works great to get the attribute changes, but how do I get those new features?

var attInspector = this.editor.attributeInspector;

alert("attInspector = " + attInspector);

attInspector.on("attribute-change", function(evt) {

   alert("Attribute changed");

   feature = evt.feature;

   //more code follows...

});

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

River Taig,

   The event you should be listening for is the events from the actual FeatureLayer. The FeatureLayer has a before-apply-edits event that you can hook into that should work for you.

https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#event-before-apply-edits

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

River Taig,

   The event you should be listening for is the events from the actual FeatureLayer. The FeatureLayer has a before-apply-edits event that you can hook into that should work for you.

https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#event-before-apply-edits

RiverTaig1
Occasional Contributor

Thank you Robert.  I ended up listening for edits-complete doing something like this: Please let me know if this looks crazy wrong (seems to work though)

function setUpListener(map) {

  featureLayerCount = map.graphicsLayerIds.length;

  for(i = 0; i < featureLayerCount; i++){

      var layerID = map.graphicsLayerIds;

      var fLayer = map.getLayer(layerID);

      if(fLayer !== undefined)  {

          fLayer.on("edits-complete", OnEditsCompleteHandler);

      }

  }

}

function OnEditsCompleteHandler(evt){

  alert("it worked!  Here's the data: " + evt);

}

RobertScheitlin__GISP
MVP Emeritus

River Taig,

  Looks good to me.

0 Kudos