Watch on LayerList Not Working 4.3

1012
1
Jump to solution
05-01-2017 09:38 AM
RaymondIrwin
New Contributor II

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.

0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

Worked for me in this example where I remove a layer from the list 

JS Bin - Collaborative JavaScript Debugging 

View solution in original post

1 Reply
KellyHutchins
Esri Frequent Contributor

Worked for me in this example where I remove a layer from the list 

JS Bin - Collaborative JavaScript Debugging