0

我正在使用 Jquery 自动完成。http://api.jqueryui.com/autocomplete/

我面临的问题是,当这个 jquery 自动完成获取我的结果时,它在一行中显示了我所有的结果。我希望它应该显示 10 个结果并在滚动中休息。

$("#<%=txtProductName.ClientID %>").autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: '<%=ResolveUrl("~/Service.asmx/GetProductAutoComplete") %>',
                        data: "{ 'prefix': '" + request.term + "'}",
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item.split('-')[0],
                                    ID: item.split('-')[1],
                                    rt: item.split('-')[2]

                                };
                            }));
                        },
                        error: function (response) {
                            alert(response.responseText);
                        },
                        failure: function (response) {
                            alert(response.responseText);
                        }
                    });
                },
                select: function (e, i) {
                    $("#<%=txtQuantity.ClientID %>").val('1');
                    $("#<%=hdfProductID.ClientID %>").val(i.item.ID);

                },
                minLength: 0,
                autoFocus: true,
                scroll:true


            });
4

1 回答 1

2
<style>
.ui-autocomplete {
    max-height: 100px;
    overflow-y: auto;
    /* prevent horizontal scrollbar */
    overflow-x: hidden;
    /* add padding to account for vertical scrollbar */
    padding-right: 20px;
}
/* IE 6 doesn't support max-height
 * we use height instead, but this forces the menu to always be this tall
 */
* html .ui-autocomplete {
    height: 100px;
}
</style>
于 2012-11-06T15:50:32.807 回答