0

我正在使用 jQueryMobile 制作移动应用程序。该应用程序将显示有关教育机构的信息,例如:有关在该机构工作的每个人的详细信息,有关每门课程的信息等。对于提到的每个项目,该应用程序都将在新页面(屏幕)上显示其相关信息。

由于类别的数量可能有数百页,我需要知道动态生成页面的选项是什么。

首先想到的是执行以下操作:

给定一个这样的 JSON 对象:

{
    "data": [
        {
            "name": "Paul",
            "image": "http://images1.wer.nocookie.net/Paul.jpg",
            "content": "<p> Paul is the bla bla that <a href=\"/wiki/PAULO\" title=\"PAULO\">PAULO</a> gives to blabla.</p>"
        },
        {
            "name": "Dr. Larry",
            "image": "http://images2.wer.nocookie.net/DRLarry.jpg",
            "content": "<p>Dr. Lawrence (Larry) is a psychologist blabla.</p>"
        }
    ]
}

我用 jQueryMobile 这样处理它:

$(document).bind('pagebeforeshow', '#home', function(){      
                $.ajax({
                    url: "cast.json",
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        ajax.parseJSON(result);
                    }
                });         
            });
            var ajax = {  
                parseJSON:function(result){
                    $('#contenido').append('<h1>'+result.data[1].name+'</h1><h2>' + result.data[1].content+ '</h2> <img alt="dsdsd" src="'+result.data[1].image+'">');
                }
            }

对于这个页面:

<body>
        <div data-role="page" id="home" data-add-back-btn="true">
            <div data-role="header" >
                <h1>This is the header
            </div>  

            <div data-role="content">
                <div id="contenido"></div>

            </div>

        </div>
    </body>

但我什至不知道这是否是一个好方法。您认为什么是好的解决方案?

我想用PhoneGap 制作应用程序。

提前致谢。

4

0 回答 0