I'm appending a Search Results to the google places javascript api autocomplete.
So far I'm 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 on 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');
});
The problem? The click event never fires...
Any idea why? Anything wrong with my code?
It seems that the click-event for .pac-container is cancelled by the Autocomplete-instance. Use mousedown instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With