在jQueryUI自动完成中手动触发“自动完成选择”

在jQueryUI自动完成中手动触发“自动完成选择”,jquery,jquery-ui-autocomplete,Jquery,Jquery Ui Autocomplete,我已经使用jQuery Autocomplete设置了一个自定义渲染解决方案 // save a reference to the widget itself to override methods var widget = $('#ui-search').on('autocompleteselect', function(e) { console.log('I am tracking the events from OUTSIDE'); }).autocomplete({ /*

我已经使用jQuery Autocomplete设置了一个自定义渲染解决方案

// save a reference to the widget itself to override methods
var widget = $('#ui-search').on('autocompleteselect', function(e) {
    console.log('I am tracking the events from OUTSIDE');
}).autocomplete({
    /***** REMOVE THIS and 'autocompleteselect' does nothing *****/
    select: function(ui, item) {
        console.warn('I am tracking this from INSIDE');  
    },
    /***** *****/
    source: projects

}).data('ui-autocomplete');

// bind clicks on the autocomplete list to trigger the 'select' event
$('.ui-autocomplete').on('click', 'li', function(e) {
    var item = $(this).data('ui-autocomplete-item');
    // use the widget's internal trigger method for generating the right kinds of events
    widget._trigger('select', $.Event('autocompleteselect'), item);
})

// this is the custom rendering method and is only relevant in that it does not include an anchor tag
widget._renderItem = function( ul, item ) {
    return $( "<li>" ).data('ui-autocomplete-item', item).html(item.label + "<br>" + item.desc).appendTo( ul );
};
我试图实现的最终结果是,单击列表项将选择该选项,而单击元素内部的按钮将显示该选择的信息面板。这部分已经完成,不相关

除非我定义了自定义选择处理程序,否则autocompleteselect小部件不会响应autocompleteselect事件。如果我删除自定义选择方法,小部件将不执行任何操作。我可以定义一个自定义处理程序来设置输入值并关闭建议列表,但我不明白为什么默认处理程序不启动

是否有人成功触发自动完成事件并让默认处理程序响应?有人知道为什么这不能或者不应该像我期望的那样工作吗


fiddle使用jQuery1.9.1和UI1.9.2;在本地,我使用jQuery 1.9.1和UI 1.10.3。环境之间的行为没有差异。

您使用的是哪个版本的jQuery UI?@haim770$1.9.1,UI1.9.2;添加到帖子中。不加评论的否决票?我遗漏了什么?我只是+1,因为我同意这不仅仅是一个合理的问题。