Google places api autocomplete - add click event

I am adding search results to google javascript api autoload.

So far I am doing this:

var autocomplete;  
  function initialize() {
    var myLatlng = new google.maps.LatLng(40.738793, -73.991402);
    autocomplete = new google.maps.places.Autocomplete(document.getElementById('autocomplete'));
  }

later i have this:

$('.pac-container').append( '<div class="j-search pac-item-refresh">Search Results</div>' );

$(document.body).on('click', '.pac-container .j-search', function(e) {
    console.log('click fired');
});

Problem? The click event never fires ...

Any idea why? Is there something wrong with my code?

+4
source share
1 answer

The click-event for seems to be .pac-containercanceled with Autocomplete-instance. Use instead mousedown.

+12
source

All Articles