带有类别可单击链接的jquery自动完成不起作用

带有类别可单击链接的jquery自动完成不起作用,jquery,ajax,autocomplete,Jquery,Ajax,Autocomplete,我为我的网站实现了自动搜索模块,工作正常。 现在的问题是,当用户键入它开始建议结果时,现在我想让这些结果可点击。 我的代码是 <input type="text" class="form-control input-lg" style="font-size:20px;padding-left:5px" name="query" id="search" required /> Jquery $( function() { $.widget("custom.catco

我为我的网站实现了自动搜索模块,工作正常。
现在的问题是,当用户键入它开始建议结果时,现在我想让这些结果可点击。
我的代码是

<input type="text" class="form-control input-lg" style="font-size:20px;padding-left:5px" name="query" id="search" required />  

Jquery

  $( function() {
   $.widget("custom.catcomplete", $.ui.autocomplete, {
   _renderMenu: function(ul, items) {
    var that = this, 
    currentCategory = "";
    $.each(items, function(index, item) {
    if (item.category != currentCategory) {
     ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>");
     currentCategory = item.category;
       }
     that._renderItemData(ul, item);
     });
     }
    });
   $( "#search" ).catcomplete({
   source : function(request,response){
    var term = $("#search").val();
    $.ajax({
      type : "GET",
      url : "ajax/auto_search.php",
      dataType : "json",
      data : {term : term},
      success : function(data)
      {
        console.log(data);
        response($.map(data.list, function(item) {

                return {
                    value: item.content_title,
                    label: item.content_title,
                    category: item.category_name
                };  
            }));
            }
           });
          }

         });
        });
$(函数(){
$.widget(“custom.catcomplete”,$.ui.autocomplete{
_renderMenu:功能(ul,项目){
var=这个,
currentCategory=“”;
$。每个(项目、功能(索引、项目){
如果(item.category!=当前类别){
ul.追加(“
  • ”+item.category+“
  • ”); currentCategory=item.category; } 即._renderItemData(ul,项目); }); } }); $(“#搜索”).catcomplete({ 来源:功能(请求、响应){ var term=$(“#搜索”).val(); $.ajax({ 键入:“获取”, url:“ajax/auto_search.php”, 数据类型:“json”, 数据:{term:term}, 成功:功能(数据) { 控制台日志(数据); 响应($.map(data.list,函数(项)){ 返回{ 值:item.content\u title, 标签:item.content\u title, 类别:item.category\u名称 }; })); } }); } }); });
    注意:当用户悬停在建议的结果上时,它会在控制台jqueryui.min.js:7 Uncaught TypeError:无法读取未定义的属性“value”