简体   繁体   English

Uncaught TypeError:未定义不是函数jQuery自动完成

[英]Uncaught TypeError: undefined is not a function jquery autocomplete

i am trying to use jquery autocomplete component.i want to show images in autocomplete.so i have to write _renderMenu and _renderIItem function.i wrote a code : 我正在尝试使用jQuery自动完成组件。我想在自动完成中显示图像,所以我必须编写_renderMenu和_renderIItem函数。我编写了一个代码:

 var _filterUser = $('#filterUser').autocomplete({
                    source: onEditLoadUsers,
                    select: onEditSelectUser,
                    focus: onEditFocusUser
                }); 
 $('#filterUser').data("autocomplete")._renderItem= function( ul, item ){
    console.log('coming here');
    return $( "<li>" )
           .append( $( '<img src="'+item.photo+'" />' ) )
           .appendTo( ul );
 };
 $('#filterUser').data("autocomplete")._renderMenu= function(ul,items){
     var that = this;
     console.log('ul is')
     console.log(ul);
     console.log(items);
     $.each( items, function( index, item ) {
         that._renderItemData( ul, item );
     });                       
 };

if i remove _renderItem function and _renderMenu function then simple autocomplete is working but when i add these two function it gave me error : 如果我删除_renderItem函数和_renderMenu函数,则简单的自动完成功能正常工作,但是当我添加这两个函数时,它给了我错误:

Uncaught TypeError: undefined is not a function FullCalendar?sfdc.tabName=01ri0000000sqRT:359
(anonymous function) FullCalendar?sfdc.tabName=01ri0000000sqRT:359
v.extend.each jquery.min.js:2
$.data._renderMenu FullCalendar?sfdc.tabName=01ri0000000sqRT:358
a.widget._suggest jquery-ui.min.js:5
a.widget.__response jquery-ui.min.js:5
(anonymous function) jquery-ui.min.js:5
onEditLoadUsers FullCalendar?sfdc.tabName=01ri0000000sqRT:779
a.widget._search jquery-ui.min.js:5
a.widget.search jquery-ui.min.js:5
(anonymous function)

i am using jquery 1.8.3 and jquery UI 1.8 .Please guideline how to resolve this error ?? 我正在使用jquery 1.8.3和jquery UI 1.8。请指导如何解决此错误?

You can not extend the object in such a way. 您不能以这种方式扩展对象。

Try this way: 尝试这种方式:

(function ($, undefined) {
    var ac = $.ui.autocomplete.prototype;
    if (typeof $.uix !== "object") { $.uix = {}; }

    ac = $.extend({}, ac, {
        _renderItem: function (ul, item) {
            console.log('coming here');
            return $("<li>")
                .append($('<img src="' + item.photo + '" />'))
                .appendTo(ul);
        },
        _renderMenu: function (ul, items) {
            var that = this;
            console.log('ul is')
            console.log(ul);
            console.log(items);
            $.each(items, function (index, item) {
                that._renderItemData(ul, item);
            });
        }
    });

    $.uix.autocomplete = ac;
    $.widget("uix.autocomplete", $.uix.autocomplete);
})(jQuery);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery自动完成 - 未捕获TypeError:undefined不是函数 - jQuery autocomplete - Uncaught TypeError: undefined is not a function jQuery Uncaught TypeError:$(…).autocomplete不是函数 - jQuery Uncaught TypeError: $(…).autocomplete is not a function jQuery的,遗漏的类型错误:未定义是不是一个函数 - Jquery, Uncaught TypeError: undefined is not a function 未捕获的TypeError:undefined不是jQuery的函数 - Uncaught TypeError: undefined is not a function with jQuery 未捕获的TypeError:undefined不是函数-不是JQuery - Uncaught TypeError: undefined is not a function - not JQuery 未捕获的TypeError:undefined不是函数jquery - Uncaught TypeError: undefined is not a function jquery 未捕获的TypeError:undefined不是函数(jQuery和jQuery Easing) - Uncaught TypeError: undefined is not a function (jQuery & jQuery Easing) 未捕获的TypeError:$(…).autocomplete不是函数 - Uncaught TypeError: $(…).autocomplete is not a function JQuery 自动完成:未捕获的类型错误:无法读取未定义的属性“值” - JQuery autocomplete: Uncaught TypeError: Cannot read property 'value' of undefined 未捕获的TypeError:无法读取未定义的JQUERY自动完成的属性&#39;length&#39; - Uncaught TypeError: Cannot read property 'length' of undefined JQUERY autocomplete
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM