【发布时间】:2015-02-22 15:35:28
【问题描述】:
我使用来自 json 请求的数据创建了一个列表视图。列表视图填充,我想单击列表视图项目并转到更详细的页面。我需要检索 #page4 上单击的列表项的 value.id1。我正在使用单页 jquery 移动模板。我知道下面的方法不正确,但希望它能让我对我想要完成的工作有所了解。使用 jquery mobile 的单页模型将数据(value.id1)从列表中传递到另一个页面的最佳方法是什么?
$("#podList").click(function(){
var listHtml ="<li>Select a date</li>";
var driverid = $("#driverid").val();
var url = "podHistory.php"
$.post(url,{ driver: driverid } , function(response){
var json = $.parseJSON(response);
$.each(json, function(key, value){
listHtml += "<li><a href='#page4?=" + value.id1 + "'>" + value.date + "</a></li>";
});//end each
$("#history").html(listHtml);
$('ul').listview('refresh');
});//end post podlist
});//end pod list click
$("#page4").on("pagebeforeshow", function () {
var page = $(this);
var query = page.data("url").split("?")[1];
var id = query.split("=")[1];
// console.log(id);
});
【问题讨论】:
标签: jquery json listview jquery-mobile