【问题标题】:Use Two pages in single html in JqueryMobile在 JqueryMobile 中使用单个 html 中的两个页面
【发布时间】:2013-10-16 09:39:56
【问题描述】:

我在 android 上使用带有手机间隙的 jquery mobile 来创建一个移动应用程序。我在单个 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”页面,但它不起作用,谁能帮我找出这个问题?

【问题讨论】:

  • 什么是#runticketsgrid
  • 我的错应该是“ticketsgrid”

标签: html jquery-mobile cordova


【解决方案1】:

改变

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

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

其他链接也是如此。

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

【讨论】:

  • 谢谢,手机还是不行,请问有什么正当理由要改href标签
  • 是的,因为 href 标记的值必须是您定位的 id。如果不相同,则无法正常工作。
【解决方案2】:
<!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> 

【讨论】:

    猜你喜欢
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 2014-05-04
    • 2018-08-30
    • 1970-01-01
    • 2014-06-15
    • 2013-07-29
    • 1970-01-01
    相关资源
    最近更新 更多