我已經解析了TableView中的json數據。爲表視圖的代碼如下─如何在PhoneGap中的文本視圖中分隔行值?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css">
</head>
<body>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Cars</h1>
<a href="levels.html" data-role="button" data-inline="true" data-mini="true">Back</a>
</div>
<div data-role="main" class="ui-content" style="margin-top:-20px;">
<h2></h2>
<ul data-role="listview" id="listid">
</ul>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript">
$(function()
{
$.getJSON("json/details.json",function(data)
{
var html="";
for(var d in data.cars)
{
for(var i in data.cars[d])
{
html+= "<li><a href=''>"+data.cars[d][i].model+" <p>"+data.cars[d][i].doors+"</p></a></li>";
}
}
$("#listid").append(html);
})
.done(function()
{
$("#listid").listview().listview("refresh");
});
});
</script>
</div>
</body>
</html>
現在給出的,當我點擊第一行,它應該在兩個測試視圖分開秈和四門,像這個 -
請給我建議。提前致謝 !!
嘗試我們的代碼,但即時得到沒有在模擬器 – ChenSmile
喜,@ImranKhan首先你需要添加兩個格或textarea的這兩個id在你的html頁面中是#model和#door,然後在span標籤內添加data.cars [d] [i] .model。 – Ved
我的第一頁有問題,第二頁在這裏http://pastebin.com/ZfEs27QZ。現在我想從第一頁導航到第二頁。 – ChenSmile