AnsweredAssumed Answered

connect to on (layer-add-result)

Question asked by cleotokos on Oct 29, 2015
Latest reply on Oct 30, 2015 by cleotokos

I'm trying to set up an alert box to fire if my layers do not load to let the user know which ones did not load. I am not sure why when I convert from some sample code I found using dojo.connect, it no longer works.

 

This works:

 

    var arrayErrors = [];
    dojo.connect(mapObj, "onLayerAddResult", function(error){
    if (error) {
        var errMess = error.message;
        arrayErrors.push(errMess);
        alert("Added to array\n" + errMess);
    }
});

 

Whereas this does not:

 

var arrayErrors = [];
on(mapObj, "layer-add-result", function(error){
    if (error) {
        var errMess = error.message;
        arrayErrors.push(errMess);
        alert("Added to array\n" + errMess);
    }
});

 

Using dojo.connect in the first code block, the alert box pops up with the error message for each service that does not load. In the second code block the alert box does not pop up at all. However if I put an alert box before the "if" block, that one will pop up - so for some reason an error is  not being logged? Does anyone see any problems in my code?

Outcomes