JQueryMobile 无法在第二页上运行

发布于 2024-12-10 15:52:57 字数 8297 浏览 0 评论 0原文

我正在使用jquery mobile 开发一个android 的phonegap 项目。该应用程序可以正常工作,但我需要在应用程序的开头添加一个新页面。一旦我完成此操作,当我导航到第二页时,jquery mobile 就无法工作。有人知道这有什么原因吗?

我所有的 javascript/jquery 都位于 main.js

这里是第一页和第二页

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PhoneGap Demo With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0b2.css" type="text/css" charset="utf-8" />
      <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css" charset="utf-8" />
      <script type="text/javascript" src="jquery.mobile/jquery-1.6.2.min"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
      <script src="jquery.mobile/jquery.mobile-1.0b2.js"></script>
          <script type="text/javascript" charset="utf-8" src="main.js"></script>

    <!-- CDN Respositories: For production, replace lines above with these uncommented minified versions -->
    <!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />-->
    <!-- <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>-->
    <!-- <script src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>-->
    </head>
  <body data-theme="a">
    <div data-role="page" data-theme="a">
    <div data-role="header">
        <img src="images/joycard.png" alt="JoyCard" class="banner">
    </div>
    <div data-role="content">

        <h3>Partner News</h3>

            <div data-role="collapsible-set">
                <div data-role="collapsible" data-collapsed="false">
                    <h3>13 Kanus</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>A Lounge</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Kino</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Action Sport Berlin</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>13 Kanus</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>A Lounge</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Kino</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Action Sport Berlin</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>

            </div>
            <div id="example">
                <h2 onclick="toIndex();">To the app</h2>
            </div>

        </div> 
    </div>
  </body>
</html>




<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PhoneGap Demo With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0b2.css" type="text/css" charset="utf-8" />
      <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css" charset="utf-8" />
      <script type="text/javascript" src="jquery.mobile/jquery-1.6.2.min"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
      <script src="jquery.mobile/jquery.mobile-1.0b2.js"></script>
      <script type="text/javascript" charset="utf-8" src="main.js"></script>
          <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>


    <!-- CDN Respositories: For production, replace lines above with these uncommented minified versions -->
    <!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />-->
    <!-- <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>-->
    <!-- <script src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>-->
    </head>
  <body data-theme="a">
    <div data-role="page" data-theme="a">
        <div data-role="header">
            <img src="images/joycard.png" alt="JoyCard" class="banner">
        </div>
        <div data-role="navbar">
            <ul>
                <li><a onclick="categoriesList();" class="ui-btn-active">KATEGORIEN</a></li>
                <li><a onclick="mapDetails();">IN DER N&Auml;HE</a></li>
                <li><a onclick="allPartners();">ALLE PARTNER</a></li>
            </ul>
        </div><!-- /navbar --> 


        <div id="list" data-role="content" data-theme="a">
            <ul data-role="listview" data-inset="true" data-theme="a">
            </ul>
        </div><!-- end jqm content -->

        <div id="allPartners" data-role="content">  
            <ul data-role="listview" data-inset="true" data-theme="a">
            </ul>
        </div><!--/all partners list -->    

        <div id="loctext" ></div>

        <div id="map_canvas" class="mapView"></div>

        <div id="menu" data-role="content" class="menu" onClick="hideMenu();">
                    <a href="news.html" class="menu-item"><img src="images/news.png" alt="News"></a>
                    <a href="contact.html" class="menu-item"><img src="images/contact.png" alt="Contact"></a>
                    <a href="info.html" class="menu-item"><img src="images/info.png" alt="Info"></a>
        </div>
    </div>
  </body>
</html>

I am working on a phonegap project for android using jquery mobile. The app worked find but I needed to add a new page to the start of the app. Once I have done this jquery mobile doesn't work when I navigate to the second page. Does anybody know any reasons for this?

All of my javascript/jquery is located on main.js

here are the first and seconds pages

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PhoneGap Demo With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0b2.css" type="text/css" charset="utf-8" />
      <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css" charset="utf-8" />
      <script type="text/javascript" src="jquery.mobile/jquery-1.6.2.min"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
      <script src="jquery.mobile/jquery.mobile-1.0b2.js"></script>
          <script type="text/javascript" charset="utf-8" src="main.js"></script>

    <!-- CDN Respositories: For production, replace lines above with these uncommented minified versions -->
    <!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />-->
    <!-- <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>-->
    <!-- <script src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>-->
    </head>
  <body data-theme="a">
    <div data-role="page" data-theme="a">
    <div data-role="header">
        <img src="images/joycard.png" alt="JoyCard" class="banner">
    </div>
    <div data-role="content">

        <h3>Partner News</h3>

            <div data-role="collapsible-set">
                <div data-role="collapsible" data-collapsed="false">
                    <h3>13 Kanus</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>A Lounge</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Kino</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Action Sport Berlin</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>13 Kanus</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>A Lounge</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Kino</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>
                <div data-role="collapsible">
                    <h3>Action Sport Berlin</h3>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dictum, est nec adipiscing interdum, felis diam pharetra leo, ut tempus magna arcu eu enim. Etiam facilisis condimentum neque tempus bibendum.</p>
                </div>

            </div>
            <div id="example">
                <h2 onclick="toIndex();">To the app</h2>
            </div>

        </div> 
    </div>
  </body>
</html>




<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PhoneGap Demo With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0b2.css" type="text/css" charset="utf-8" />
      <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css" charset="utf-8" />
      <script type="text/javascript" src="jquery.mobile/jquery-1.6.2.min"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
      <script src="jquery.mobile/jquery.mobile-1.0b2.js"></script>
      <script type="text/javascript" charset="utf-8" src="main.js"></script>
          <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>


    <!-- CDN Respositories: For production, replace lines above with these uncommented minified versions -->
    <!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" />-->
    <!-- <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>-->
    <!-- <script src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>-->
    </head>
  <body data-theme="a">
    <div data-role="page" data-theme="a">
        <div data-role="header">
            <img src="images/joycard.png" alt="JoyCard" class="banner">
        </div>
        <div data-role="navbar">
            <ul>
                <li><a onclick="categoriesList();" class="ui-btn-active">KATEGORIEN</a></li>
                <li><a onclick="mapDetails();">IN DER NÄHE</a></li>
                <li><a onclick="allPartners();">ALLE PARTNER</a></li>
            </ul>
        </div><!-- /navbar --> 


        <div id="list" data-role="content" data-theme="a">
            <ul data-role="listview" data-inset="true" data-theme="a">
            </ul>
        </div><!-- end jqm content -->

        <div id="allPartners" data-role="content">  
            <ul data-role="listview" data-inset="true" data-theme="a">
            </ul>
        </div><!--/all partners list -->    

        <div id="loctext" ></div>

        <div id="map_canvas" class="mapView"></div>

        <div id="menu" data-role="content" class="menu" onClick="hideMenu();">
                    <a href="news.html" class="menu-item"><img src="images/news.png" alt="News"></a>
                    <a href="contact.html" class="menu-item"><img src="images/contact.png" alt="Contact"></a>
                    <a href="info.html" class="menu-item"><img src="images/info.png" alt="Info"></a>
        </div>
    </div>
  </body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假装不在乎 2024-12-17 15:52:58

如果您现在只使用一个 html,则必须使用 id 来引用页面:

< div data-role="page" data-theme="a" id=“first_page”>

< div data-role="page" data-theme="a" id=“第二页”>
......................
转到第一页
..........

您必须知道的一件重要的事情是,一个 html 文件内的页面列表中的第一页将是第一个,因此在这种情况下,first_page 将在启动屏幕后显示。

在另一种情况下(使用不同的 html 文件)不需要在第二、第三和其他不是 index.html 的页面中包含 de 样式,因为所有内容都默认使用 js 加载。因此,首先加载index.html,然后加载jqm stats,然后其他页面将使用ajax加载,至少您禁用然后或使用外部rol。

If you are using now onlye one html, you msut referer the pages with the id:

< div data-role="page" data-theme="a" id=¨first_page¨ >

< div data-role="page" data-theme="a" id=¨second_page¨ >
.............
Go to the first page
..........

One importat thing you must know is that the first page in the list of pages inside one html file will be first, so in this case first_page will me showed after the splash screen.

In the other case (using different html files) isn´t necesary include de styles in the seconds, third and other pages that arent the index.html, becouse all is loaded by default with js. So first is lodaded the index.html and then the jqm stats to work, then the other pages will be loaded with ajax at least you disable then or use external rol.

酒解孤独 2024-12-17 15:52:57

我猜这是带您进入第二页的链接?

<h2 onclick="toIndex();">To the app</h2>

这个函数有什么作用?是否使用这个功能:

$.mobile.changePage("secondpage.html");

I'm guessing that this is the link that takes you to the second page?

<h2 onclick="toIndex();">To the app</h2>

What does this function do? Is it using this function:

$.mobile.changePage("secondpage.html");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文