0

I have an infowindow that pops up when a google maps marker is clicked. All of the content is enclosed in quotes including buttons and dropdowns and set using infowindow.setcontent();

I'm having some issues on mobile with multiple things firing(such as the selection dropdown) when buttons are tapped. This isn't an issue on PC. I've done some research and it seems the jquery method stopPropagation() would help me, however I'm stuck on how to access the button because it's enclosed in quotes. Nothing happens when I press the button. Here's what I'm trying currently. This does work for buttons that aren't in quotes.

$(document).ready(function(){
$("#button2").click(function(event){
    event.stopPropagation();
    alert('test');
    //method to be executed
});
}); 

the button

var content ='<input type="button" id="button2"value="Mark checked">';  
a can
  • 5
  • 3
  • Assuming you're appending the HTML of `content` to the DOM after the page has loaded, you'll need to use a delegated event handler. I'm confused how this could be working at all on any platform if that was the case, though. – Rory McCrossan Oct 18 '18 at 15:17

1 Answers1

0

I guess this is about the infowindows in Google Maps v3? They get created when you click the marker (you click the marker, and the content is appended to a div). And you can't hook an event to something that's not already in the dom.

The solution is creating a callback. For more information I suggest looking at this post link

Peter Bode
  • 222
  • 1
  • 9