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...
});
Solved! Go to Solution.
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
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
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);
}
River Taig,
Looks good to me.