首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery UI自动完成- that._renderItemData不是一个函数

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

Stack Overflow用户
提问于 2013-01-06 06:45:24
回答 1查看 2.6K关注 0票数 1

我使用简单的类别示例 of jQuery UI自动完成并将其集成到我的应用程序中。当我开始输入我的搜索栏时,我得到了错误"TypeError: that._renderItemData不是一个函数“在Firebug中。

我也有一个jQuery无冲突。

代码语言:javascript
复制
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 = this替换var

代码语言:javascript
复制
 var that = $(this)

和

代码语言:javascript
复制
var that = jQuery(this)

但这两个选项都会抛出相同的错误。如何解决这一冲突?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-06 07:01:59

类别是jQuery UI 1.9中的新内容。我吃的是1.8.3。

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

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14180016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档