I have this code inside the success function of a jQuery ajax call success: function(d)
for (var n in d.items)
{
google.maps.event.addListener(markers[d.items[n].id], 'mouseover', function() {
focusMarker(d.items[n].id);
});
}
Unfortunately, the function always evaluated d.items[n].id
as the last item in d.items
collection.
I tried making this modification:
for (var n in d.items)
{
var id = d.items[n].id;
google.maps.event.addListener(markers[d.items[n].id], 'mouseover', function() {
focusMarker(id);
});
}
but my function always returned the same thing.
Is this a scope problem, or is there something wrong with my function definition?