按类别的Jquery自动完成不返回选定的结果

我试图从类别示例中得到自动完成的结果列表框值,并且我无法像其他示例那样使用它。 我一定在做一些愚蠢的事情。

    
    $.widget( "custom.catcomplete", $.ui.autocomplete, {
        _renderMenu: function( ul, items ) {
            var self = this,
                currentCategory = "";
            $.each( items, function( index, item ) {
                if ( item.category != currentCategory ) {
                    ul.append( "" + item.category + "" );
                    currentCategory = item.category;
                }
                self._renderItem( ul, item );
            });
        },
                /* I ADDED THIS */
        select: function(event, ui){
alert(ui.item.value); } }); $(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 }); }); </script>


我想到了。 我需要把它放在这里:

$("#search").catcomplete({
    delay: 0,
    source: data,
    select: function(event, ui){
    alert(ui.item.label);
    }
});
链接地址: http://www.djcxy.com/p/62445.html

上一篇: Jquery autocomplete by categories not returning selected result

下一篇: Using SlowCheetah Config Transforms on Web.config in a 3.5 Web Forms app