jQuery UI自动完成-that._renderItemData不是函数 [英] jQuery UI autocomplete - that._renderItemData is not a function
问题描述
我以jQuery UI Autocomplete的简单类别示例并将其集成到我的应用程序中.当我开始在搜索栏中输入内容时,在Firebug中收到错误"TypeError:that._renderItemData不是函数" .
I took the simple categories example of jQuery UI Autocomplete and integrated it in my application. When I started typing in my search bar, I get the error "TypeError: that._renderItemData is not a function" in Firebug.
我也有一个没有冲突的jQuery.
I also have a jQuery no conflict.
jQuery(document).ready(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 );
});
}
});
$(function() {
var data = [
{ label: "anders", category: "" },
{ label: "andreas", category: "" },
{ label: "antal", category: "" },
{ label: "annhhx10", category: "Products" },
{ label: "annk K12", category: "Products" },
{ label: "annttop C13", category: "Products" },
{ label: "anders andersson", category: "People" },
{ label: "andreas andersson", category: "People" },
{ label: "andreas johnson", category: "People" }
];
$( "#search" ).catcomplete({
delay: 0,
source: data
});
});
我认为这是由于冲突.所以我尝试将var that = this替换为
I think this is because of the conflict. So I tried replacing var that = this with
var that = $(this)
和
var that = jQuery(this)
但是两个选项都抛出相同的错误.如何解决此冲突?
But both option is throwing the same error. How to resolve this conflict?
推荐答案
类别是jQuery UI 1.9的新增内容.我当时有1.8.3.
Categories is new to jQuery UI 1.9. I was having 1.8.3.
使用最新的1.9.2 jQuery JS解决了该问题.
Using the latest 1.9.2 jQuery JS fixed the problem.
这篇关于jQuery UI自动完成-that._renderItemData不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!