0
使用jquery ui自動填充與谷歌地圖API(http://code.google.com/p/geo-autocomplete/)在用戶輸入時提示位置。用戶選擇其中一個建議後,我想更新頁面上的鏈接。我這樣做:用戶選擇自動完成提示後更新鏈接
$.widget("ui.geo_autocomplete", {
// setup the element as an autocomplete widget with some geo goodness added
_init: function() {
this.options._geocoder = new google.maps.Geocoder; // geocoder object
this.options._cache = {}; // cache of geocoder responses
this.element.autocomplete(this.options);
// _renderItem is used to prevent the widget framework from escaping the HTML required to show the static map thumbnail
this.element.data('autocomplete')._renderItem = function(_ul, _item) {
return $('<li></li>').data('item.autocomplete', _item).append(this.options.getItemHTML(_item)).appendTo(_ul);
};
},
// default values
options: {
change: function() {
//change the link
},
的問題是,用戶選擇後的建議,然後點擊了其他位置的頁面上只執行切換功能。如果他們選擇一個建議,然後立即點擊鏈接,它還沒有被更新。如何在用戶選擇其中一個提示建議後立即更新鏈接?