Click event in Google Map InfoWindow not caught

user244129 picture user244129 · Feb 7, 2010 · Viewed 12k times · Source

With Google Map v2, I would like to be able to trigger a function when clicking a text in the InfoWindow of a GMarker.

$(".foo").click(myFunction);

...

marker.openInfoWindowHtml("<span class=\"foo\">myText</span>");

does not work. Why the event isn't caught inside the InfoWindow ?

Answer

steven picture steven · May 16, 2013

I couldnt get it working like Kevin Gorski explained...

with jquery 1.9.1 and maps api v=3.exp the following works:

infowindow.setContent('<a href="#" id="test">test</a>');
google.maps.event.addDomListener(infowindow, 'domready', function() {
    $('#test').click(function() {
        alert("Hello World");
    });
});