dpkrbe395930 2013-04-29 01:43
浏览 113
已采纳

使用jquerymobile和php创建移动应用程序

i have created the login page for my web application using php, where i converted the result into json and grabed the list with jquery. Now my problem is that the list is a hyperlink to another page. So when user selects a name from the list, they should be redicted to another page and see all the information in ragards to that patient. But i dont know how i can grab and display the selected patient on another page.

Ideally i am thinking of creating another function which gets the json results from php file and saves it in an jquery array. Now when the user selects a patient. The id of the patient will then be compared with the one in the list, so if it matches up, then display everything related to that patient but on another page.

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');
  • 写回答

2条回答 默认 最新

  • duanba8173 2013-04-29 09:23
    关注

    Take a look at my other answer: jQuery Mobile: Sending data from one page to the another, there you will find several solutions to your problem.

    Basically you want something like this: 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);
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题