Luke
Luke

Reputation: 199

Google maps click event on anchor for telephone

I currently have a map with markers for Stores. When clicked on a map, I get the popup which contains store related details. All the markers are pushed into an array as usual. I'm adding a listener as below for each marker to populate a popup with store details using jquery template.

google.maps.event.addListener(marker, 'clickFromList', function() {
    ......
    $('.store-info').on('click', '.tel', function(e){
       //do something
    });
    ......
});

Now I need to capture on click event for telephone in the popup (anchor tag) created for the marker as shown in above.

My popup is something like below.

<div class="store-info">
......
<a class="tel" href="tel:xxxxx">xxxxxxxx</a>
......
</div>

Now first time when I click on a marker and get the popup and then click on anchor it won't trigger the event. But when I close one popup and open another popup from different marker, it triggers as expected.

Just for testing I tried adding the anchor click event outside in the maps addlistener but no luck.

I know there's nothing much for you to investigate, but appreciate if anyone can help. Thanks

Upvotes: -1

Views: 173

Answers (1)

Luke
Luke

Reputation: 199

I was able to fix this issue and I'll leave it here if anyone want it.

store-info is a dynamic class generated via the jquery template in infowindow. Hence I have replaced it with a further up parent class to register the click event and resolved the issue.

Upvotes: 0

Related Questions