views:

724

answers:

3

First off this is my - Test Site

This is my testing playground for Google maps, I am not concerning myself with aesthetics. What I am having trouble with is getting some jQuery to fire when I click on a link inside of the info window. If you are familiar with Google Maps this is where I create my infowindow:

GEvent.addListener(marker,"click", function() {
map.openInfoWindow(point,'<div class="infoWindow">'+windowText+'\
'+<a href='#' class='showme' onclick='return false;'>Show Comments</a>+'\
</div>');       

/*On click, show all the comments*/
$('.showme').live('click', function(){
    //alert('hey');
    $('.comment').toggle('slow');
});

                                             });

To understand how it works, it might be easier just to view the source on the page. Originally I had instead of using a "live event" been doing a normal "on click" which did not work. I was assuming because the info window was its own environment apart from the main window.

This was wrong I believe when I tried the "live event" and it began to work in Chrome and FF. So now I am trying to understand why the click event doesn't work in any browser, and why the live event would work in everything but IE.

Does anyone have any input?

Thanks,
Levi

Edit:Sorry, if it wasn't clear the "show comments" link in the info window is where my trouble lies.

+2  A: 

It seems there are some issues with using jquery's live() functionality with IE. There was a recommendation here to try bind instead. I've read in some other places that using a different mouse event can work as well, such as mouseup or mousedown. It definitely seems like an IE bug, though.

Joseph
Oh wow, that did the trick. I would still be curious to know why regular click events don't work inside the info window but I will have to research that a bit more.
Levi
A: 

The livequery plugin seems to work in info windows with IE.

$('.showme').livequery(function(){
  $(this).click(function(){
    $('.comment').toggle('slow');
  });
});
Markus
A: 

Changing the live('click',...) to live('mouseup', ...) fixed it in my case.

RichardAtHome