jQuery UI自动完成 - that._renderItemData不是一个函数

Len*_*ran 1 jquery jquery-ui jquery-ui-autocomplete

我采用了jQuery UI Autocomplete 的简单类别示例,并将其集成到我的应用程序中.当我开始在搜索栏中输入内容时,我在Firebug中收到错误"TypeError:that._renderItemData不是函数".

我也有一个jQuery没有冲突.

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
    });

});
Run Code Online (Sandbox Code Playgroud)

我认为这是因为冲突.所以我尝试用=替换var = this

 var that = $(this)
Run Code Online (Sandbox Code Playgroud)

var that = jQuery(this)
Run Code Online (Sandbox Code Playgroud)

但这两个选项都抛出同样的错误.如何解决这个冲突?

Len*_*ran 5

类别是jQuery UI 1.9的新增功能.我有1.8.3.

使用最新的1.9.2 jQuery JS解决了这个问题.