nLayersAddResult not being successful

433
2
10-08-2012 09:55 PM
JosephShanahan
New Contributor
I have the onLayersAddResult setup  as follows


dojo.connect(map, "onLayersAddResult", initEditing,initEditingError);

I have setup the two callback functions

    function initEditing(results) {
      console.log("init initEditing");       
      var featureLayerInfos = dojo.map(results, function(result) {         
       return {'featureLayer': result.layer};
       }
       );       
}

function initEditingError(err){
  console.log("Init editing error")
  console.log(err);

}


I am only loading one layer so the event to set it going is as follows

var featureLayer = new esri.layers.FeatureLayer("http://lap-303754:6080/arcgis/rest/services/Birds/Birdsightings/FeatureServer/0",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,         
outFields: ["*"] });       

map.addLayers([featureLayer]);


However it in not being called correctly and the initEditingError method is being called.

err outputs the following to the console
error = undefined, more information here would be helpful
layer all of the layer attributes, can't see anything wrong here
success = true which implies according to esri help the layer was added successfully.

Any ideas why will it not call initEditing.
The service appears to be setup correctly and I have reworked my javascript to come at this from various angles.

Thanks
Joseph Shanahan
ESRI Australia
0 Kudos
2 Replies
derekswingley1
Frequent Contributor

I have setup the two callback functions


Dojo.connect doesn't work that way.

The behavior of dojo.connect changes depending on how many arguments are provided. By providing four args, you're causing your 3rd argument to be treated as a JS context for the 4th argument.

In this case, I recommend using three arguments to dojo.connect and check for success or failure of loading your layers looking at result.success to see if your layer was loading successfully or not.
0 Kudos
JosephShanahan
New Contributor
Thank you
Problem fixed

Joseph Shanahan
ESRI Australia
0 Kudos