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
Following should give you the count of currently visible li
s in a listview
with id=myList
$('#myList li').size() - $('#myList li.ui-screen-hidden').size()
http://jsfiddle.net/nirmaljpatel/Vy7Vu/
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With