How To Detect Button Click In Googlemaps Infowindow
Using Googlemaps V3 I am trying to add a button to the infoWindow on my googlemap. The infoWindows and button appear as expected. I am trying to capture the onclick event of the
Solution 1:
The button isn't added to the DOM until the infowindow completes rendering. You can't find it with getElementById (or the jquery equivalent) until after the infowindow domready event fires.
var contentBtn = '<p><button id="marker'+numby+'" class="iwLink" href="#" >Done</button></p>';
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(address+contentBtn);
infowindow.open(map, this);
});
google.maps.event.addListener(infowindow, 'domready', function() {
google.maps.event.addDomListener(contentBtn, 'click', function() {
alert($(this).attr('id'));
});
});
Post a Comment for "How To Detect Button Click In Googlemaps Infowindow"