[英]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.