1

php を使用して Web アプリケーションのログイン ページを作成しました。結果を json に変換し、jquery でリストを取得しました。今私の問題は、リストが別のページへのハイパーリンクであることです。そのため、ユーザーがリストから名前を選択すると、別のページにリダイレクトされ、その患者に関するすべての情報が表示されます。しかし、選択した患者を別のページに取得して表示する方法がわかりません。

理想的には、json の結果を php ファイルから取得し、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');
4

2 に答える 2

1

私の他の答えを見てください: jQuery Mobile: Sending data from one page to another、そこにはあなたの問題に対するいくつかの解決策があります。

基本的には、次のようなものが必要です: 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);
});
于 2013-04-29T09:23:43.937 に答える