Howdy all,
An easy question for the pros:
In the "LayerList widget with actions" sample code (https://developers.arcgis.com/javascript/latest/sample-code/widgets-layerlist-actions/index.html) the code gives some actions to a layer. I've modified that example to add a "save" button that writes a cookie with the currently visible layers, so I can reload the page and have my new default layers be visible. However, when I add more layers, the save button shows up on each layer and each sublayer. I was looking for a way to have the save button appear once, but I don't really want it as part of any specific layer. Is there a way to do this?
This is what I have so far:
//LayerListWidget initialization
var layerList = new LayerList({
view: view,
listItemCreatedFunction: onLayerWidgetStartup
});
function onLayerWidgetStartup(event) {
var item = event.item;
item.actionsSections = [[{
title: "Save Layer visibility",
className: "esri-icon-save"
}]];
//rest of stuff to write cookies
Since I'm calling onLayerWidgetStartup for each listItem, I get a Save Layer button on each.
Solved! Go to Solution.
HFOW#$FHOW#@HFW THIS CLEARS UP SO MUCH!! Thank you very much for your time. I have a javascript for beginners book ordered, but it hasn't arrived yet. Thanks for being my JavaScript for Dummies, Robert!
One thing I notice on a quick review is your require modules don't match your function arguments. watchUtils is in the wrong order.