Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find the count of visible list items in search filter jQuery mobile

I have implemented a phone gap app for android using jQuery Mobile and java script.

in my app

I have added a list view dynamically and used search filter attribute (true).

Now i want to popup an alert for every search.

That alert sh'd shows the count of the visible list items for entering of every character.

how?

Thnaks in advance

like image 828
user1425472 Avatar asked Jul 17 '12 07:07

user1425472


2 Answers

Following should give you the count of currently visible lis in a listview with id=myList

$('#myList li').size() - $('#myList li.ui-screen-hidden').size()

http://jsfiddle.net/nirmaljpatel/Vy7Vu/

like image 127
Nirmal Patel Avatar answered Sep 26 '22 00:09

Nirmal Patel


I have made you an example on that does what you want: http://jsfiddle.net/Calavoow/ddTX9/3/

It uses the css selector from this topic for quick counting of elements.

The javascript code uses a listview with id="filterlist".

$(document).on("pageshow", function() {
    $("#filterlist").prev().on("keyup",function(){
        count();
    });
});

function count(){
    var elements = $("#filterlist li:visible").length;
    alert(elements);
}
like image 36
Calavoow Avatar answered Sep 26 '22 00:09

Calavoow