<!DOCTYPE html>
<html>
<head>
<title>JQM latest</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/git/jquery.mobile-git.css">
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://jquerymobile.com/demos/1.3.0-rc.1/js/jquery.mobile-1.3.0-rc.1.js"></script>
<script>
$(document).on("pageinit", function() {
$('#mylist').on('listviewbeforefilter', function(e, data) {
var $ul = $( this ),
$input = $( data.input ),
value = $input.val(),
html = "";
$ul.html( "" );
if ( value && value.length > 2 ) {
$ul.html( "<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>" );
$ul.listview( "refresh" );
$.ajax({
url: "http://gd.geobytes.com/AutoCompleteCity",
dataType: "jsonp",
crossDomain: true,
data: {
q: $input.val()
}
})
.then( function ( response ) {
$.each( response, function ( i, val ) {
html += "<li>" + val + "</li>";
});
$ul.html( html );
$ul.listview( "refresh" );
$ul.trigger( "updatelayout");
$ul.find('li').on( "click", function() {
$input.val($( this ).text());
});
});
}
});
});
</script>
<style>
#edit-with-js-bin { display: none !important; }
</style>
</head>
<body>
<div data-role="page">
<div data-role="content" id="content">
<form class="ui-filterable">
<!--<input type="text" data-type="search" id="myinput">-->
<ul data-role="listview" data-inset="true" data-filter="true" data-filter-reveal="true" data-input="#myinput" id="mylist">
</ul>
</form>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>
见演示:http: //jsbin.com/ivEZUJU/5/