我刚刚开始使用 jQuery Mobile 框架,并想将我最初设置为表格的网格修改为表格。我面临的问题是我只从我的 XML 解析中获取第一行数据,尽管有 8 条数据要输入。
我猜网格会自动为它找到的每个新集合添加一行,而它在 tabe 布局中没有找到,并且可能需要为它找到的每条数据添加某种“每个”——我不知道该怎么做案例,但如果有人可以提供帮助,我将非常感激 - 谢谢。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Table</title>
<!--Standard Jquery Stuff here-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<!--Set the Icons to be used if saved to an apple home screen-->
<link rel="apple-touch-icon" href="_/images/iOS_Icons/iPhoneIcon.png" />
<link rel="apple-touch-icon" sizes="72x72" href="_/images/iOS_Icons/iPadIcon.png" />
<link rel="apple-touch-icon" sizes="114x114" href="_/images/iOS_Icons/iPhoneIcon@2x.png" />
<link rel="apple-touch-icon" sizes="144x144" href="_/images/iOS_Icons/iPadIcon@2x.png" />
<!-- Custom css -->
<link rel="stylesheet" href="../_/css/Michaels.css" />
<!-- dpv feed-->
<script type="text/javascript">
var xml;
$(document).ready(function(){
$.ajax({
type: "GET",
url: "../_/xml/dpv.xml",
dataType: "xml",
success: xmlParser
});
});
//loading XML file and parsing to .main div.
function xmlParser(data) {
xml = data;
$('#load').fadeOut();
$(xml).find("location").each(function () {
var name = $(this).find("name").text();
var target = $(this).find("target").text();
var actual = $(this).find("actual").text();
var thru = $(this).find("thru").text();
var lastmod = $(this).find("lastmodified").text();
$("#dpvtable").append('<tr><th><a href="dpv_graphs/dpv-' + name + '.html" rel="external">'+name+'</a></th><td>' + actual + '</td><td>' + target + '</td><td>' + thru + '</td></tr>');
$('#dpvtable').tableview('refresh');
});
}
</script>
</head>
<body>
<!-- DPV -->
<div data-role="page" id="dpv">
<div data-role="header" data-position="fixed">
<h1>DPV</h1>
</div>
<div data-role="content" data-theme="a" >
<ul id="table" data-role="tableview">
<li id="load">Loading Data...</li>
</ul>
<table data-role="table" id="dpvtable" data-mode="columntoggle" class="ui-responsive table-stroke">
<thead>
<tr>
<th>Location</th>
<th data-priority="1">DPV</th>
<th data-priority="1">Target</th>
<th data-priority="2">Thru</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!--Footer-->
<div data-role="footer" style="text-align:center" data-position="fixed">
<a class="ui-btn-left" data-icon="home" style="margin: float" href="../index.html" data-transition="flip">Home</a>
</div>
</body>