I got a problem when I try to set EventListenr for each DOM object inside an array. the function that I define for each DomEvent becomes the same for all of them (console.log(key) prints the same key(last key in loop) for all of the items). my code is like this:
var dom = {};
var popupContent = L.DomUtil.create('div');
for(var key in this._info){
dom[key] = L.DomUtil.create('a', "", popupContent);
dom[key].innerHTML = key;
dom[key].href = "#";
L.DomEvent.on(dom[key], 'click', function(){
//do some stuff
console.log(key);
});
}
var popup = L.popup();
popup.setLatLng(latlng)
.setContent(popupContent)
.openOn(this._map);
Thank you in advance for any help you can give me :)