JQuery Mobile: view list view function

Hi, so I want the filter search to be such that you enter two letters of the search, and the corresponding results are displayed as a list. I cannot load the whole list, as is typical for jqm listview, because it is too large. Can someone please show me how to do this ... this is a bit beyond understanding the API.

I know how to use the autocomplete widget for jquery, but I want the results to be formatted as a list. So, the text box, and then below it the results of the listview formatting, but only after two letters were entered, I would like to display the results, so it does not display a giant list that takes too long to load.

+5
source share
2 answers

Take a look here: https://github.com/commadelimited/autoComplete.js
Looks like what you are looking for.
Alex

+1
source

I assume your call returns JSON:

$("#txtInput").change(function() {
   var val = $(this).val();
   if (val.length >= 2)
   {
       // Do Ajax call
        $.ajax({
        type: "POST",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        url: '/SomeURL/',
        data: "{'searchText': '" + val + '}',
        success: function (data) {
           $("#divListArea").empty();
           var i;
           for (i = 0; i < data.length; i++)
           {
              $("#divListArea").append("<div key=" + data[i].Id + ">" + data[i].SomeProperty + "</div>");
           }
           $("#divListArea div").each(function() {
              $(this).click(function() [
                 // Do something
                 var id = $(this).attr('key');
              });
           });
         },
         complete: function () {

         }
    });
   }
});
0
source

All Articles