Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui catcomplete的文档_Jquery Ui - Fatal编程技术网

Jquery ui catcomplete的文档

Jquery ui catcomplete的文档,jquery-ui,Jquery Ui,我只是想找到catcomplete的文档。我需要如何使用renderItem的手册。我发现了这一点,但似乎没有提到这一点,只是举了一个例子 _renderMenu: function( ul, items ) { var that = this, currentCategory = ""; $.each( items, function( index, item ) { if ( item.category

我只是想找到catcomplete的文档。我需要如何使用renderItem的手册。我发现了这一点,但似乎没有提到这一点,只是举了一个例子

    _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 );
        });
    }
\u renderMenu:功能(ul,项目){
var=这个,
currentCategory=“”;
$。每个(项目、功能(索引、项目){
如果(item.category!=当前类别){
ul.追加(“
  • ”+item.category+“
  • ”); currentCategory=item.category; } 即._renderItemData(ul,项目); }); }
    catcomplete
    只是一个示例,不幸的是,它不是jQuery UI的一部分,因此没有关于
    \u renderItem
    renderMenu
    的文档。将此作为jQuery源代码的一部分。然而,效果可以很容易地从源代码中复制出来

    要使用catcomplete,我们只需确保将
    标签
    类别
    值传递给
    catcomplete
    ,如下所示:

    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" }
    ];
    
    类别为空字符串的项目将不会放入类别中,并保留为标准的自动完成。给定类别的将在该类别下细分

    (关于jQuery示例)


    要向每个项目添加类,只需将
    .addClass(item.category)
    附加到
    catcomplete
    小部件中最后一行代码的末尾:

    that._renderItemData( ul, item ).addClass(item.category);
    

    谢谢,但我的问题是我想为该项目添加额外的类,所以请按类别名称(class='ui-corner-all-People')指定它,谢谢。猴子是我,不是你:)