在这里,我用......你必须用自己的代码只添加href标记代码:
$(document).on("pageinit", "#myPage", function() {
$("#autocomplete").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://ws.geonames.org/searchJSON",
dataType: "jsonp",
crossDomain: true,
data: {
featureClass: "P",
style: "full",
maxRows: 12,
lang: "it",
name_startsWith: $input.val()
}
})
.then(function (response) {
$.each(response.geonames, function (i, val) {
html += "<li>" + val.name + (val.adminName1 ? ", " + val.adminName1 : "") + ", " + val.countryName + "</li>";
});
$ul.html(html);
$ul.listview("refresh");
$ul.trigger("updatelayout");
});
}
});
});