Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>$.getJSON('BookList.json', function(data) { var output='&lt;ul id="List" data-role="listview"&gt;'; for (var i = 0; i &lt; 5; i++) { output+="&lt;li&gt;" + BookList.UniqueIndex + ": " + BookList.Title + " | " + BookList.published +"&lt;/li&gt;"; }; output+="&lt;/ul&gt;"; $("#ListDiv").append(output); $('#List').listview(); }); </code></pre> <p>This code should work. As I mentioned in my comment, the data-role and id are properties so you need to specify them within the or add them using $("#List").attr()</p> <p>Also when you add in a listview completely dynamically you must initialize it by calling .listview() before you call any other listview methods. If your listview was already declared in HTML and you were just updating it, then you would just call listview("refresh").</p> <p>Here's the fiddle I was playing with: <a href="http://jsfiddle.net/HQLdd/1/" rel="nofollow">JSFiddle Example</a></p> <p>Quick edit: I think your second code section would actually work if you were just using </p> <pre><code>output += "&lt;li&gt;" + data.BookList[i].UniqueIndex + ": " + data.BookList[i].Title + " | " + data.BookList[i].published +"&lt;/li&gt;"; </code></pre> <p>instead of "output=" (And the .listview() replacement we talked of earlier). The "+=" makes sure that you are appending the string to the end of what's already there, the "=" just replaces the string with a new one each time.</p> <p>I didn't run this code though since the above example is working.</p> <p>Also, Alkis has some good explanations for some of the changes I made also. So make sure to check his/her answer out!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload