Home Limit ajax autocomplete results
Reply: 0

Limit ajax autocomplete results

user861
1#
user861 Published in May 23, 2018, 7:20 am

How do you limit the number of search result given that the data is not local. I know local data can be easily limited as shown below.

source: function(request, response) {
    var results = $.ui.autocomplete.filter(myarray, request.term);

    response(results.slice(0, 10));`

This is not working quite well when I get my data externally. Below is my code.

 $(function() {
  $("#search").autocomplete({
    source: "/accounts/ajax/search/",
    minLength: 2,
    select: function(event, ui ){
        window.open(ui.item.url,'_self')},
    open: function(event, ui) {
        $('.ui-autocomplete').append("<li><a class = \" text-primary\" href='javascript:document.getElementById(\"search_form\").submit();'> See All Result </a></li>");
         },
  });
});
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.381096 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO