看一下这个。希望这个解决方案对你有用。
http://jsfiddle.net/dxS8f/
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>
$(document).bind('pageinit', function() {
var listJSON = [
{ item : 'Apple', category : 'Fruites'},
{ item : 'Banana', category : 'Fruites'},
{ item : 'Beans', category : 'Vegetables'},
{ item : 'Carrot', category : 'Vegetables'},
{ item : 'Potatoes', category : 'Vegetables'},
{ item : 'Spinach', category : 'Vegetables'},
{ item : 'Strawberry', category : 'Fruites'}
];
$.each(listJSON, function(i, field){
$('#mylist').append('<li>'+field.item+'</li>').listview('refresh');
});
var yourFilterFunction = function( text, searchValue, item ){
var flag = false,
sCat = null;
categoryVal = $("#optCategory").val().toLowerCase();
$.each(listJSON, function(i, field) {
if(field.item === text) {
sCat = field.category;
}
});
flag = (text.toString().toLowerCase().indexOf(searchValue) > -1) && ((sCat.toLowerCase() === categoryVal || categoryVal === ''));
return !flag;
};
$("#mylist").listview('option', 'filterCallback', yourFilterFunction);
$("#optCategory").bind('change', function() {
var inputTxt = $("input.ui-input-text").val();
$(".ui-input-text").trigger("keyup");
$.each(listJSON, function(i, field) {
yourFilterFunction(field.item, inputTxt, $("#mylist").children().eq(i));
});
});
});
</script>
</head>
<body>
<div data-role="page" id="HelloPage">
<header data-role="header" class="header">
<a href="#" data-rel="back">Back</a>
<h5>jQuery Mobile</h5>
</header>
<div data-role="content">
<select id="optCategory" data-mini="true">
<option value="" >Select One</option>
<option value="Fruites">Fruites</option>
<option value="Vegetables">Vegetables</option>
</select>
<br/>
<ul id="mylist" data-role="listview" data-inset="true" data-filter="true">
</ul>
</div>
<footer data-role="footer" data-position="fixed"><h5>© All rights reserved</h5></footer>
</div>
</body>
</html>