0
我正在使用jQuery地理自動填充插件來將位置建議爲用戶類型(http://code.google.com/p/geo-autocomplete/)。擴展/覆蓋jQuery UI自動完成功能
一旦用戶選擇了一個建議,我想編輯頁面上的鏈接。我試圖擴展選擇功能。我已經定義了一個新的選擇功能來覆蓋核心功能。以下是javascript的示例:
$.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: {
select: function(event, ui) {
alert('in override function');
},
用戶選擇其中一個建議後,將顯示警報,然後填充文本框。我希望執行核心選擇功能(從而填充文本框),然後擁有我的代碼以執行(我將更改鏈接的href)。我怎樣才能做到這一點?
我需要觸發我自己的功能的用戶點擊了一個建議之後。當用戶第一次開始在輸入框中輸入時,不會.trigger('change')調用我的函數? – user1056675 2012-08-10 13:49:54