我试图在 jquerymobile listview 中显示所有联系人。不幸的是,我只列出/显示了一个联系人。我使用的代码如下。谢谢
function onDeviceReady() {
// find all contacts with 'Bob' in any name field
var options = new ContactFindOptions();
options.filter="";
options.multiple=true;
var fields = ["displayName", "phoneNumbers", "photos"];
navigator.contacts.find(fields, onSuccess, onError, options);
}
// onSuccess: Get a snapshot of the current contacts
//
function onSuccess(contacts) {
for (var i=0; i<contacts.length; i++) {
if(null != contacts[i].phoneNumbers)
{
for(var j=0;j<contacts[i].phoneNumbers.length;j++)
{
$('.real').append("<li'><a><img src='foto/user.png'/><h4 >" + contacts[i].displayName +"</h4><p>"+ contacts[i].phoneNumbers[j].value +"</p></a> </li>").listview('refresh');
}
}
}
}
// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}