谷歌地方API自动完成 - 添加点击事件 [英] google places api autocomplete - adding click event
本文介绍了谷歌地方API自动完成 - 添加点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将一个搜索结果追加到google位置javascript api autocomplete中。
I'm appending a Search Results to the google places javascript api autocomplete.
到目前为止,我正在这样做: p>
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?
推荐答案
看起来, .pac-container
被 Autocomplete
-instance取消。改为使用 mousedown
。
It seems that the click-event for .pac-container
is cancelled by the Autocomplete
-instance. Use mousedown
instead.
这篇关于谷歌地方API自动完成 - 添加点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文