简体   繁体   English

Jquery UI自动完成的限制结果

[英]Limiting results of Jquery UI autocomplete

I wanted to ask, how can I limit results of search. 我想问一下,如何限制搜索结果。 This is piece of code, responsible for quering. 这是一段代码,负责查询。 I want to have only five autocomplete items. 我只希望有五个自动完成项。

Source: 资源:

 function( request, response ) {
        $.ajax({
            type : 'post',
            dataType: "json",
            data: {
                'person':request
            },

            url: 'PersonWatch/all',

            success: function(data) {
                response( $.map( data, function(item, i) {
                        return item.person
                }));
            }
        });
    }

Try 尝试

response($.map(data, function(item, i) {
             return i < 5 ? item.person : null
         })
        );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM