我正在使用pagebeforeshow到一个页面来获取getjson数据,并从该页面一次又一次地显示同一页面,然后再次点击返回页面之前,同样从该特定页面转到下一页。任何建议,谢谢。
代码如下,
$(document).on('pagebeforeshow', '#pagethree', function(e) {
//alert("inpGrid");
var i = 0;
var url = "http://192.168.0.101:8080/iConfig/html5_XV/slideDemo/json/listinp.json";
// var url = "http://api.openweathermap.org/data/2.5/forecast?lat=35&lon=139&callback=?" ;
$.getJSON(url, function(res) {
console.log(res)
var attr = "";
$.each(res.response.output.records, function(i, v) {
$.each(res.response.output.fieldInfo, function(index, value) {
if (index == 0 && offset==v[value["label"]]) {
attr =1;
}
if(attr == 1){
if(index == 0){
document.getElementById('inpName').value = v[value["label"]];
inpName = v[value["label"]];
}
if(index == 1){
document.getElementById('inpAlias').value = v[value["label"]];
inpAlias = v[value["label"]];
}
if(index == 2){
document.getElementById('inpDataType').value = v[value["label"]];
inpDataType = v[value["label"]];
}
if(index == 3){
document.getElementById('inpDefault').value = v[value["label"]];
inpDefault = v[value["label"]];
}
if(index == 4){
document.getElementById('inpVisible').value = v[value["label"]];
inpVisible = v[value["label"]];
attr = "";
}
}
});
});
});
});
和pagethree.html看起来像
<html>
<body>
<div data-role="page" data-dialog="true" id="pagethree" data-close-btn="none">
<div data-role="header">
<h1>Selected Input</h1>
</div>
<div data-role="main" class="ui-content" style="height:300px;" >
<div class="ui-field-contain">
<fieldset data-role="controlgroup">
<div data-role="fieldcontain">
<label for="name">Name:</label>
<input type="text" name="inpName" id="inpName" disabled="disabled"/>
</div>
<div data-role="fieldcontain">
<label for="name">Alias:</label>
<input type="text" name="inpAlias" id="inpAlias"/>
</div>
<div data-role="fieldcontain">
<label for="name">Data Type:</label>
<input type="text" name="inpDataType" id="inpDataType" disabled="disabled"/>
</div>
<div data-role="fieldcontain">
<label for="name">Default Value:</label>
<a href="listDefault.html" data-transition="slide"><input type="text" name="inpDefault" id="inpDefault" /></a>
</div>
<div data-role="fieldcontain">
<label for="name">Visibility:</label>
<select name="inpVisible" id="inpVisible">
<option value="0">0</option>
<option value="1">1</option>
</select>
</div>
</fieldset>
</div>
<a href="" data-role="button" data-theme="b" id="save1" data-inline="true" data-rel="back">back</a>
<a href="slidingdialogs.html">Go to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text in Dialog</h1>
</div>
</div>
</body>
</html>