使用jquery和php创建一个移动应用程序


Creating a Mobile application using jquerymobile and php

我使用php为我的web应用程序创建了登录页面,在那里我将结果转换为json并使用jquery抓取列表。现在我的问题是,该列表是一个超链接到另一个页面。因此,当用户从列表中选择一个名字时,他们应该被跳转到另一个页面,并看到该患者的所有信息。但是我不知道如何在另一个页面上抓取和显示选定的患者。

理想情况下,我正在考虑创建另一个函数,从php文件中获取json结果,并将其保存在jquery数组中。现在当用户选择一个病人。然后将患者的id与列表中的id进行比较,因此如果匹配,则显示与该患者相关的所有内容,但在另一个页面上。

var url = 'http://brandon.walesalami.com/nurseD.php';
$.get(url,function (data){
   //var renderHtml = '<div data-role="list-view"></div>';
   var listView = $('<ol data-role="listview" data-inset="true"></ol>');
    for (var i in data.patient)
        {
            var li = $('<li class="patientSel"><a href="#profile" class="' + data.patient[ i ].id + '">' + data.patient[ i ].name + '</a></li>').appendTo(listView);
        }
        $('#co').replaceWith(listView); 
    }, 'json');

看看我的另一个答案:jQuery Mobile:将数据从一个页面发送到另一个页面,在那里你会找到几个解决你的问题的方法。

基本上你需要这样做:http://jsfiddle.net/Gajotres/eAYB9/

$(document).on('pagebeforeshow', '#index', function(){       
    $('#test-listview li a').each(function(){
        var elementID = $(this).attr('id');      
        $(document).on('click', '#'+elementID, function(event){  
            if(event.handled !== true) // This will prevent event triggering more then once
            {
                localStorage.itemID = elementID; // Save li id into an object, localstorage can also be used, find more about it here: https://stackoverflow.com/questions/14468659/jquery-mobile-document-ready-vs-page-events
                $.mobile.changePage( "#second", { transition: "slide"} );
                event.handled = true;
            }              
        });
    });
});
$(document).on('pagebeforeshow', '#second', function(){       
    $('#second [data-role="content"]').html('You have selected Link' + localStorage.itemID);
});

直接使用jQuery移动本地存储

jQuery Mobile -添加本地存储
如何在jQuery Mobile中使用HTML5本地存储