Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
JQueryUI 1.10.0自动完成渲染问题_Jquery_Jquery Ui_Jquery Ui Autocomplete - Fatal编程技术网

JQueryUI 1.10.0自动完成渲染问题

JQueryUI 1.10.0自动完成渲染问题,jquery,jquery-ui,jquery-ui-autocomplete,Jquery,Jquery Ui,Jquery Ui Autocomplete,我尝试了一个将“自动完成”重命名为“ui自动完成”的解决方案(使用JQueryUI 1.10.0、JQuery 1.8.3),但仍然收到以下错误: 类型错误:$(…)。自动完成(…)。数据(…)未定义 它在1.10.0中定义,但我需要覆盖: _renderItem: function( ul, item ) { return $( "<li>" ) .append( $( "<a>" ).text( item.label ) ) .appendTo( ul ); },

我尝试了一个将“自动完成”重命名为“ui自动完成”的解决方案(使用JQueryUI 1.10.0、JQuery 1.8.3),但仍然收到以下错误:

类型错误:$(…)。自动完成(…)。数据(…)未定义

它在1.10.0中定义,但我需要覆盖:

_renderItem: function( ul, item ) {
return $( "<li>" )
.append( $( "<a>" ).text( item.label ) )
.appendTo( ul );
}, 
\u renderItem:功能(ul,项目){
返回$(“
  • ”) .append($(“”).文本(item.label)) .附录(ul); },
  • 这是我的全部代码:

    var ajaxCall_QuickSearchCompanyId;
                $('#QuickSearchCompanyId').autocomplete({
                    minLength: 2, delay: 300, source: function (request, response) {
                        if (ajaxCall_QuickSearchCompanyId) {
                            ajaxCall_QuickSearchCompanyId.abort();
                        }
                        ajaxCall_QuickSearchCompanyId = $.ajax({
                            url: '/Advertiser/Autocompleter/CompaniesDetailed', dataType: 'json',
                            data: { q: request.term },
                            success:
                                function (data) {
                                    $('#QuickSearchCompanyId').removeClass('ui-autocomplete-loading');
                                    response($.map(data, function (item) {
                                        return {
                                            label: item.ID,
                                            value: item.Name,
                                            subsidiaries: item.Subsidiaries,
                                            category: item.Category,
                                            url: (item.URL == null) ? '' : item.URL,
                                            parentName: item.ParentName,
                                            isReported: item.IsReported
                                        }
                                    }));
                                }
                        });
                    }
                }).data('ui-autocomplete')._renderItem = function (ul, item) {
                    String.prototype.chunk = function (n) {
                        var ret = []; for (var i = 0, len = this.length; i < len; i += n) { ret.push(this.substr(i, n)); }
                        return ret;
                    }; ul.attr('id', 'ul_QuickSearchCompanyId'); return $('<li></li>')
                        .data('ui-autocomplete-item', item)
                        .append("<a style='padding: 0px;'><div style='margin-bottom: 0px; width: 450px;'><table style='height: 100%; width: 450px; font-family: Calibri; font-size: 10pt;'><tr><td style='width: 280px; border-right: solid 1px Black; padding: 0px; color: " + ((item.isReported != true) ? 'Gray' : 'Black') + "; font-style: " + ((item.isReported != true) ? 'italic' : 'none') + ";'>" + ((item.parentName != '[[root]]') ? (item.parentName + ': ') : '') + item.value + "</td><td align='right' valign='top' style='width: 150px; padding: 0px; color: " + ((item.isReported != true) ? 'Gray' : 'Black') + "; font-style: " + ((item.isReported != true) ? 'italic' : 'none') + ";'>" + item.category + "<br /></td></tr></table></div></a>")
                        .appendTo(ul);
                };
    
    var ajaxCall\u QuickSearchCompanyId;
    $('QuickSearchCompanyId')。自动完成({
    最小长度:2,延迟:300,来源:函数(请求,响应){
    if(ajaxCall\u快速搜索公司ID){
    ajaxCall_QuickSearchCompanyId.abort();
    }
    ajaxCall\u QuickSearchCompanyId=$.ajax({
    url:“/Advertiser/Autocompleter/CompanysDetailed”,数据类型:“json”,
    数据:{q:request.term},
    成功:
    功能(数据){
    $('#QuickSearchCompanyId')。removeClass('ui-autocomplete-loading');
    响应($.map)(数据、功能(项){
    返回{
    标签:item.ID,
    值:item.Name,
    子公司:项目。子公司,
    类别:项目。类别,
    url:(item.url==null)?“”:item.url,
    parentName:item.parentName,
    isReported:item.isReported
    }
    }));
    }
    });
    }
    }).data('ui-autocomplete')。\u renderItem=函数(ul,项){
    String.prototype.chunk=函数(n){
    var ret=[];for(var i=0,len=this.length;i'))
    .data('ui-autocomplete-item',item)
    .append(“+((item.parentName!=”[[root]])?(item.parentName+“:”):“”)+item.value+“+item.category+”
    ) .附录(ul); };
    任何想法都会受到极大的赞赏。

    而不是

    $('selector').data('ui-autocomplete')._renderItem = function (ul, item) { };
    
    你应该使用

    $('selector').data('uiAutocomplete')._renderItem = function (ul, item) { };
    

    我也有同样的问题。您应该使用
    $('selector').data('autocomplete')。\u renderItem=function(ul,item){…}

    或者只需打开控制台并键入如下内容:
    $('div').autocomplete().data()

    在这里,您将看到必须使用的方法。在我的例子中,它只是“自动模拟”

    我找到了解决方案! 好吧,我将和你分享我的一点经验。当我遇到同样的问题时,我听到人们谈论将“ui自动完成”更改为“uiAutocomplete”或只是“autocomplete”,但这是错误的

    正确的答案是“ui自动完成”,解决这个问题的方法不是这个。当我从以下位置更改代码时,我可以解决问题:

        .data('ui-autocomplete')._renderItem = function (ul, item)
    
    至:

        .__renderItem = function(ul, item)
    

    试着这样做,然后告诉我发生了什么。

    我对这一行也有同样的问题

    .data("autocomplete")._renderItem = function (ul, item) {
    
    我可以通过添加任何这些来克服错误

    1 - .data('ui-autocomplete')._renderItem = function (ul, item) { 
    2 - .data('uiAutocomplete')._renderItem = function (ul, item) { 
    3 - .__renderItem = function(ul, item) {
    

    刚刚尝试了这个,但没有成功:
    TypeError:$(…).autocomplete(…).data(…)未定义[在此错误上中断]
    }.data('uiAutocomplete')。\u renderItem=function(ul,item){
    @user1214620:这应该可以:。你确定你在使用1.10吗?你救了我一天!效果很好,我只需要在css中添加一点zIndex,因为自动完成列表在某些元素下显示为什么downvote?这对我很有效,我失去了这方面的时间共享知识?为什么你没有给我一个fe就进行了downvoteedback?谢谢!我用ui自动完成而不是自动完成这对我来说很有用你建议在控制台中运行JS是个好主意。帮我解决了问题。
    1 - .data('ui-autocomplete')._renderItem = function (ul, item) { 
    2 - .data('uiAutocomplete')._renderItem = function (ul, item) { 
    3 - .__renderItem = function(ul, item) {