Ok, so my happiness was way too short.

The above code works for 1 marker and 1 infowindow.
But if you have 50 markers and you start to click around, then the
clicked! alert is displayed as many time as you've clicked on a
marker...

is there any way to reset the event before I set the content in my
closure function???

Doing all this with inline js would be really easy - I could just make
a <a href="#" onlcick="javascript:blabla()">blabla</a>
and it would work as expected, but I think that doing this with
unobtrusive javascript is somehow more elegant...


On Mar 23, 12:28 pm, THE_AI <[email protected]> wrote:
> Hey Rossko!
> Thank you very much, you are genius!
> I've changed to:
> function createInfoWindow(marker, hotspot) {
>         return (function() {
>                 infowindow.setOptions({
>                         'content': hotspot.description,
>                         'position': hotspot.position
>                 });
>                 infowindow.open(map,marker);
>
>                 google.maps.event.addListener(infowindow, 'domready', 
> function() {
>                         $('direction').addEvent('click', function(){
>                                 alert('clicked!');
>                         });
>                 });
>                 }
>         );
>
> }
>
> and it seems to work now.
>
> On Mar 23, 12:24 pm, Rossko <[email protected]> wrote:
>
>
>
>
>
>
>
> > > I've tried to add an event to the direction span with mootools, plain
> > > js, google.maps.event and nothing is working and I just can't
> > > understand why???
>
> > The infowindow content doesn't exist in the DOM until the API has
> > created it, asynchronously.
> > Try listening for the infowindow's domready event before attempting to
> > access its content.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to