Py学习  »  Jquery

jQuerymobile导航栏,在单个index.html中包含多个页面

chikitin • 4 年前 • 259 次点击  

我正在尝试创建一个jQuerymobile应用程序,它有一个导航栏,在单个index.html中有多个页面。我正在使用模板 Multi-page template structure

不幸的是,我不能让导航栏显示不同的页面。这是我的代码:

我还使用了一个脚本'pageLoader.js'来强制加载页面。但这也不管用。这是我的pageLoader.js:

 <!doctype html>
<html>
    <head>
        <title>My Page</title>
        <!--https://jquerymobile.com/download/-->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-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>

        <!--POST page 1-->

        <div data-role="page" id="postPage">
            <div data-role="header">
                <h1>I'm a header</h1>
                    <div data-role="navbar">
                        <ul>
                            <li><a href="#postPage">POST</a></li>
                            <li><a href="#getPage">GET</a></li>
                                    <li><a href="#putPage">PUT</a></li>
                        <li><a href="#deletePage">DELETE</a></li>
                    </ul>
                        </div><!-- /navbar -->
            </div><!-- /header -->

            <div role="main" class="ui-content">


                <label for="key">key:</label>
                 <input type="text" name="key" id="key" placeholder="enter your key" value="" data-clear-btn="true">

                <label for="value">value:</label>
                 <input type="text" name="value" id="value" placeholder="enter your value" value="" data-clear-btn="true">

                <button onclick="saveValue()"> Store Key</button>
                <p id="status">Status: No Activity</p>

            </div><!-- /content -->

            <div data-role="footer">
                <h4>My Footer</h4>
            </div><!-- /footer -->

            <!--get Page 2-->

            <div data-role="page" id ='getPage'>

                <div data-role="header">
                    <h1>I'm a header</h1>
                        <div data-role="navbar">
                                <ul>
                                        <li><a href="#postPage">POST</a></li>
                                        <li><a href="#getPage">GET</a></li>
                                        <li><a href="#putPage">PUT</a></li>
                            <li><a href="#deletePage">DELETE</a></li>
                                </ul>
                            </div><!-- /navbar -->
                </div><!-- /header -->

                <div role="main" class="ui-content">


                    <label for="key">key:</label>
                     <input type="text" name="key" id="key" placeholder="enter your key" value="" data-clear-btn="true">
                    <button onclick ="getValue()"> Get Value</button>
                    <p id="status">Status: No Activity</p>

                </div><!-- /content -->

                <div data-role="footer">
                    <h4>My Footer</h4>
                </div><!-- /footer -->


            </div><!-- /page -->
            <script src="scripts/client.js" type="text/javascript"></script>
            <script src="scripts/pageLoader.js" type="text/javascript"></script>
    </body>
</html>

我还尝试使用脚本强制更改页面。我将pageLoader.js脚本用于以下内容:

$(document).on("pageshow", function(){
    if($('.ui-page-active').attr('id') === 'postPage'){
        $.mobile.changePage("#postPage");
    } else if ($('.ui-page-active').attr('id') === 'getPage'){
         $.mobile.changePage("#getPage");
    }
});

任何帮助都将不胜感激。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49989
 
259 次点击