【问题标题】:Creating a Mobile application using jquerymobile and php使用 jquerymobile 和 php 创建移动应用程序
【发布时间】:2013-04-29 01:43:40
【问题描述】:

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

理想情况下,我正在考虑创建另一个函数,该函数从 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');

【问题讨论】:

    标签: php jquery jquery-mobile local-storage


    【解决方案1】:

    看看我的另一个答案:jQuery Mobile: Sending data from one page to the 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);
    });
    

    【讨论】:

    • 谢谢。它完美地工作。现在如何显示所选患者的姓名?
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-14
      • 1970-01-01
      • 1970-01-01
      • 2022-08-03
      • 2017-09-17
      • 2020-09-22
      相关资源
      最近更新 更多