I am working on developing a JavaScript solution to add the alt attribute to images in map popups. Using the events listed in this repo's readme, I cannot get consistent results when changing between webmaps. I have tried the code in different topic.subscribe sections within the custom-scripts.js file.
Is there an event that fires when the webmaps change? I'll provide my sample code below. Any help is greatly appreciated:
let webmap = app.map;
webmap.on('click', function() {
// only execute code if a popup is displayed on click
if (webmap.infoWindow.isShowing) {
// img elements within the feature popup
let popupImage = document.querySelectorAll('div.image > img')[0];
if (typeof popupImage !== 'undefined') {
// popup title - bridge name
let bridgeNameElement = document.querySelectorAll('div.esriViewPopup > div.mainSection > div.header')[0].innerHTML;
// add alt attribute using bridge's name
popupImage.setAttribute('alt', bridgeNameElement);// || 'some string'
}
}
});
I am working on developing a JavaScript solution to add the
alt
attribute to images in map popups. Using the events listed in this repo's readme, I cannot get consistent results when changing between webmaps. I have tried the code in differenttopic.subscribe
sections within thecustom-scripts.js
file.Is there an event that fires when the webmaps change? I'll provide my sample code below. Any help is greatly appreciated: