我知道这是一个反复出现的问题。但我拼命地努力让这个工作。我让它工作,并在改进过程中意外删除它。请有人指出哪里出错?我知道它会变得非常明显,但我只是在圈子里去了!
我有以下jquery移动页面 - data-role =“page”id =“catalog”
<ul data-role="listview" id="authors_book_list" data-divider-theme="a" data-inset="true">
<li data-role="list-divider" data-theme="b" role="heading">Book Titles</li>
</ul>
js file:
$(document).on("pageinit", "#catalog", function () {
$('#kslaughter').click(function(){
$.getJSON('book-details.json', function(data) {
var output='<ul id="authors_book_list" data-role="listview">';
for (var i = 0; i < 5; i++) {
output+="<li>" + authors_book_list.id + ": " + authors_book_list.title + " | " + authors_book_list.publisher +"</li>";
};
output+="</ul>";
$("#authors_book_list").append(output);
$('#authors_book_list').listview('refresh');
});
});
});
书details.json
[{
"id": 0,
"title": "The Surgeon",
"author": "Tess Gerritsen",
"year published": 2010,
"publisher": "Transworld Digital",
"image": "rizzoliisles1.jpg"
}, {
"id": 1,
"title": "The Apprentice",
"author": "Tess Gerritsen",
"year published": 2010,
"publisher": "Transworld Digital",
"image": "rizzoliisles02.jpg"
}, {
"id": 2,
"title": "Keeping the dead",
"author": "Tess Gerritsen",
"year published": 2009,
"publisher": "Transworld Digital",
"image": "rizzoliisles1.jpg"
}];
请回答,告诉我哪里出错:S