I have this JSON array
// Json array
var productList = {"products": [
{"description": "product 1", "price": "9.99"},
{"description": "product 2", "price": "9.99"},
{"description": "product 3", "price": "9.99"}
]
};
I want it to loop through my list view but have no idea how to do this all I can do so far is list one item at a time. Also, I can only list the product and not the product = the price. The jQuery forum inst helping... thanks !!
Here's the rest of the code
function loadList() {
// var list = document.getElementById('productList');
var list = $("#productList").listview();
var listItem = document.createElement('li');
listItem.setAttribute('id', 'listitem');
listItem.innerHTML = productList.products[0].description;
$(list).append(listItem);
$(list).listview("refresh");
and the HTML file
<html xmlns:f="http://www.lipso.com/f" xmlns:l="http://www.lipso.com/v2/lml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<head>
<title>Page Title</title>
&meta;
<script src="@=site.cfg.resources.url@/test.js"></script>
</head>
<body onLoad="loadList()">
<div data-role="page">
<div data-role="header" id="header">
<h1>Dynamic Product List</h1>
</div>
<div data-role="content" id="content">
<ul id="productList" data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
</ul>
</div>
</div>
</body>
</html>