【问题标题】:update a link after user chooses autocomplete sugggestion用户选择自动完成建议后更新链接
【发布时间】:2012-08-13 05:39:16
【问题描述】:

我使用 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
            },

问题是change函数只有在用户选择了一个建议之后才会执行,然后点击页面上的其他地方。如果他们选择了建议,则立即单击链接,它尚未更新。如何在用户选择提示的建议之一后立即更新链接?

【问题讨论】:

    标签: jquery-ui autocomplete


    【解决方案1】:

    请改用select 事件。有关事件文档,请参阅 official documentation

    【讨论】:

      猜你喜欢
      • 2022-12-15
      • 1970-01-01
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      • 2013-03-06
      • 2021-05-20
      相关资源
      最近更新 更多