在JqueryMobile中使用单个html中的两个页面

时间:2013-10-16 09:39:57

标签: html5 jquery-mobile cordova

我正在使用jquery mobile与android之间的手机间隙创建一个移动应用程序。我在单个html文件中包含两个页面。它没有按预期工作。下面是代码剪切

<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css"/>
    <script src="JQMobile/jquery-1.9.1.min.js"></script>
    <script src="JQMobile/jquery.mobile-1.3.2.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
    <div data-position="fixed" data-role="header" data-theme="b">
        <h1>Mobile Portal</h1>
    </div>
    <div data-role="content">
        <div class="ui-grid-a">
            <div class="ui-block-a">
                <a href="#runticketsgrid" data-role="button">Tickets</a><br>
            </div>
            <div class="ui-block-b">
                <a href="#runticketsgrid" data-role="button">Second Column</a><br>
            </div>
        </div>
    </div>
</div>
<div data-role="page" id="ticketsgrid">
    <div data-role="header">
        <h1>Page Title</h1>
    </div>
    <!-- /header -->

    <div data-role="content">
        <p>Page content goes here.</p>
    </div>
    <!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div>
    <!-- /footer -->
</div>
</body>
</html>

这里我想在用户点击“Tickets”div时加载“ticketsgrid”页面,但它不起作用,有人能帮我找到这个吗?

2 个答案:

答案 0 :(得分:1)

更改

<a href="#runticketsgrid" data-role="button">Tickets</a><br>

<a href="#ticketsgrid" data-role="button">Tickets</a><br>

另一个链接也一样。

工作示例:http://jsfiddle.net/9SktP/1/

答案 1 :(得分:0)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>home</title>
    <link rel="stylesheet" href="themes/style.min.css" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile.structure-1.3.2.min.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js">  </script>
</head>    
<body>
    <div data-role="page" id="pageone">
        <div data-position="fixed" data-role="header" data-theme="b">
            <h1>Mobile Portal</h1>
        </div>
        <div data-role="content">
            <div class="ui-grid-a">
                <div class="ui-block-a">
                    <a href="demo.html#ticketsgrid"  data-transition="slide" data-role="none">Tickets</a><br>
                </div>
                <div class="ui-block-b">
                    <a href="demo.html#ticketsgrid" data-transition="slide" data-role="none">Second Column</a><br>
                </div>
            </div>
        </div>
    </div>
    <div data-role="page" id="ticketsgrid">
        <div data-role="header">
            <h1>Page Title</h1>
        </div>
        <!-- /header -->

        <div data-role="content">
            <p>Page content goes here.</p>
        </div>
        <!-- /content -->

        <div data-role="footer">
            <h4>Page Footer</h4>
        </div>
        <!-- /footer -->
    </div>
</body>     
</html>