问题
I'm trying to find an easy way to check how many list items are left after a list has been filtered.
I can pick up when the list is being filtered via
$("#theList").listview('option', 'filterCallback', function( text, searchValue ) {
//how many list items are there??
return text.toLowerCase().indexOf( searchValue ) === -1;
});
Is there an easy way to do this? I'm really looking to hook onto a filter applied event if possible. Not having much luck with the docs so any help appreciated.
回答1:
To count the remaining li showing, use the psudo-selector of ":visible" like this...
$("#theList li:visible").length
回答2:
You can also check for the presence of class ui-screen-hidden:
$('#theList li').length - $('#theList .ui-screen-hidden').length
来源:https://stackoverflow.com/questions/7897433/jquerymobile-listview-events-number-of-remaining-items-after-filter-applied