AnsweredAssumed Answered

Watch on LayerList Not Working 4.3

Question asked by RandyI2 on May 1, 2017
Latest reply on May 1, 2017 by khutchins-esristaff

Have the following code and nothing happens when the LayerList updates.  

 

var layerList = new LayerList({
view: view,
container: "layers",
createActionsFunction: defineActions

});

var listChanged = layerList.watch('operationalItems.length', function (length) {
console.log("New item added or item removed. Length " + length);
fixPopupsInList(layerList.operationalItems);
});

 

I wan to change the color of the titles to indicate the popup is enabled (works fine) when a new layer is added, but the refresh of list  removes the color indicator, so was thinking of reapplying color when popupEnabled == true on each add, but the above watch doesn't work for some reason.  Any ideas?  Thanks in advance.

 

I realize there are several workarounds, but want to understand why watch(obj, callback) isn't working and use it if can.

Outcomes