开发者

jQueryUI autocomplete not displaying more than 10 results to the user

I am currently using jquery-ui-1.8.10 I am using the autocomplete component and cannot find in the documentation any way to configure it to return more than 10 results to the user, even though the list has more than 10 results returned from the server. http://jqueryui.com/demos/autocomplete/

Here is a similar post, but max does not work for me and it feels like he is using another component other than the autocomplete one from jQueryUI, even though he says he is. jQuery autocomplete won't show more than 10 results

How can I configure the component to display more than 10 results to the user?

$("#module-name-search").autocomplete({
        source: "service/searchForModule?langCode=" + langCode,
        minLength: 3,
        max: 50,
        select: function(event, ui){
            $("#module-code-search").val(ui.item.id);
            $("#module-name-search").val(ui.item.text);

    开发者_JS百科        return false;
        }
    }).data("autocomplete")._renderItem = function(ul, item){
        return $("<li></li>").data("item.autocomplete", item).append("<a style='font-size:9px;'>" + item.text + "</a>").appendTo(ul);
    };


I found a solution to my problem... posted below is the code.

$("#module-name-search").autocomplete({
        source: function( request, response ) {
            if (searchAjax != null) {
            searchAjax.abort();
        }
        searchAjax = $.ajax({
                url: "service/searchForModule?langCode=" + langCode,
                dataType: "json",
                data: {
                    term: encodeURI(request.term),
                    iTipeProgram: $("#prog-type-input").val()
                },
                success: function( data ) {
                    //alert(data);
                    response( data );
                }
            });
        },
        minLength: 3,
        select: function(event, ui){
            $("#module-code-search").val(ui.item.id);
            $("#module-name-search").val(ui.item.text);

            return false;
        },
        open: function() {
            $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
        },
        close: function() {
            $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
        }
    }).data("autocomplete")._renderItem = function(ul, item){
        return $("<li></li>").data("item.autocomplete", item).append("<a style='font-size:9px;'>" + item.text + "</a>").appendTo(ul);
    };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜