[Javascript] problem with event assignment
Konstantine
listclient at gmail.com
Wed Jan 18 16:58:28 CST 2006
On 1/18/06, Howard Jess <howard at dhitechnologies.com> wrote:
> There are only -one- (1) each of variables named "marker" and "popup", even
> though they're declared within the for-loop. Their values are whatever they
> were assigned in the last loop.
>
> Try this (untested):
>
> var doc = request.responseXML;
> var markers = doc.documentElement.getElementsByTagName("marker");
> function addL(mrkr,popup) {
> ATGEvent.addListener(mrkr,"click",function() {mrkr.openInfo(popup)});
> }
> for (var i = 0; i < markers.length; i++) {
> var p = new Point(parseFloat(markers[i].getAttribute("x")),parseFloat(markers[i].getAttribute("y")));
> var marker = new Marker(p);
> var popup = markers[i].firstChild.firstChild.nodeValue;
> addL(marker,popup);
> }
Yep!
this does solve my problem. Thank you very much for your time and wisdom.
K
More information about the Javascript
mailing list