我有以下代码:
var options = {
types: ['(cities)'],
componentRestrictions: {country: "pl"}
};
var input: any = document.getElementById('searchTextField');
this.autocomplete = new google.maps.places.Autocomplete(input, options);
this.autocomplete.addListener('place_changed', () => {
.....
});
$('#searchTextField').focusout(function (e) {
$('.pac-container').find('.pac-item').first().click()
});
和HTML:
<input class="form-control" type="text" id="searchTextField" placeholder="City"/>
但是,现在,当用户点击输入时,如果没有选择,则不会触发place_changed
事件。如何在聚焦时触发此事件?