Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法设置属性'_renderItem';未定义的_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 无法设置属性'_renderItem';未定义的

Javascript 无法设置属性'_renderItem';未定义的,javascript,jquery,ajax,Javascript,Jquery,Ajax,这是我的密码。。。 有人能帮我吗 $(文档).ready(函数(){ /$(“#搜索输入[name=“filter_name”]”)attr(“x-webkit-speech”,“x-webkit-speech”) $(“#搜索输入[name=“输入搜索菜单”]”)。自动完成({ 来源:功能(请求、响应){ $.ajax({ url:'index.php?route=module/search\u suggestion/ajax', 数据类型:“json”, 数据:{ 关键词:request.t

这是我的密码。。。 有人能帮我吗

$(文档).ready(函数(){

/$(“#搜索输入[name=“filter_name”]”)attr(“x-webkit-speech”,“x-webkit-speech”)
$(“#搜索输入[name=“输入搜索菜单”]”)。自动完成({
来源:功能(请求、响应){
$.ajax({
url:'index.php?route=module/search\u suggestion/ajax',
数据类型:“json”,
数据:{
关键词:request.term
},
成功:函数(json){
响应($.map(json,函数(项){
返回{
字段:item.fields,
值:item.href
}
}));
}
});
},
最小长度:1,
选择:功能(事件、用户界面){
如果(ui.item.value==“”){
返回false;
}否则{
location.href=ui.item.value;
返回fse;
}
},
打开:函数(){
$(this).removeClass(“ui角点全部”).addClass(“ui角点顶部”);
},
关闭:函数(){
$(this.removeClass(“ui角顶部”).addClass(“ui角全部”);
},
焦点:功能(事件、用户界面){
$('#搜索输入[name=“filter_name”]').val(ui.item.label);
返回false;
}
}).data(“ui自动完成”)。\u renderItem=功能(ul,项目){
var元素=[];
$.each(item.fields,function(field\u name,field){
如果(字段!=未定义和字段[字段名称]!=未定义和字段[字段名称]){
变量字段_html=“”;
如果(字段名称=‘价格’){
if(字段特殊){
field_html=''+field.price+''+field.special+'';
}否则{
field_html=field.price;
} 
}否则{
field_html=字段[field_name];
}
if(field.label!=未定义&&field.label.show!=未定义&&field.label.show){
field_html=''+field.label.label+''+field_html;
}
如果(field.location!=未定义&&field.location=='inline'){
field_html=“”+field_html+“”;
}否则{
field_html=“”+field_html+“”;
}
push({sort:field.sort,html:field\uhtml});
}
});
//分类
sort(函数(a,b){返回a.sort-b.sort});
//内爆
var元素_html='';
$.each(元素、函数(索引、元素){
if(元素!=未定义){
elements\u html=elements\u html+element.html;
}
});     
返回$(“
  • ”) .data(“item.autocomplete”,item) .append(“”+元素\u html+“”) .附录(ul); };
    }))

    `我无法在js文件上设置属性“\u render\u item”。这使我的js文件停止工作。有人能帮我写代码吗

    提前谢谢

    某些与自动完成相关的命名约定在中被弃用 jQueryUI在v1.9中被删除,在v1.10中被完全删除(参见 )


    您可以在查看,因为它很好地解释了这一点。:)

    在哪里设置
    \u render\u item
    属性?
    //$('#search input[name="filter_name"]').attr("x-webkit-speech", "x-webkit-speech")
    $('#search input[name="input-search-menu"]').autocomplete({
        source: function(request, response) {
            $.ajax({
                url: 'index.php?route=module/search_suggestion/ajax',
                dataType: 'json',
                data: {
                    keyword: request.term
                },
                success: function(json) {
                    response($.map(json, function(item) {
                        return {
                            fields: item.fields,
                            value: item.href
                        }
                    }));
                }
            });
        },
        minLength: 1,
        select: function(event, ui) {
            if (ui.item.value == "") {
                return false;
            } else {
                location.href = ui.item.value;
                return fse;
            }
        },
        open: function() {
            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function() {
            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        },
        focus: function(event, ui) {
            $('#search input[name="filter_name"]').val(ui.item.label);
            return false;
        }
    }).data("ui-autocomplete")._renderItem = function(ul, item) {
    
        var elements = [];
        $.each(item.fields, function(field_name, field) {
          if (field != undefined && field[field_name] != undefined && field[field_name]) {
    
            var field_html = '';            
            if (field_name == 'price') {
              if (field.special) {
                field_html = '<span class="price-old">' + field.price + '</span><span class="price-new">' + field.special + '</span>';
              } else {
                field_html = field.price;
              } 
            } else {
              field_html = field[field_name];
            }
    
            if (field.label != undefined && field.label.show != undefined && field.label.show) {
              field_html = '<span class="label">' + field.label.label + '</span>' + field_html;
            }
            if (field.location != undefined && field.location == 'inline') {
              field_html = '<span class="' + field_name + '">' + field_html + '</span>';
            } else {
              field_html = '<div class="' + field_name + '">' + field_html + '</div>';
            }
    
            elements.push({sort: field.sort, html: field_html});
          }
        });
    
        // sort
        elements.sort(function(a, b){return a.sort-b.sort});
    
        // implode
        var elements_html = '';
        $.each(elements, function(index, element) {
          if (element != undefined) {
            elements_html = elements_html + element.html;
          }
        });     
    
        return $("<li></li>")
            .data("item.autocomplete", item)
            .append('<a class="search-suggestion">' + elements_html + '</a>')
            .appendTo(ul);
    };