2012-02-21 32 views
2

我是新來phonegap.I正在使用jQuery Mobile的使用HTML5開發Android app.I有三頁,我app.First是index.html的,它有內容的列表。第二頁有文本內容和一個帶兩個按鈕的標題,例如下一個。而第三個頁面是一樣的第二page.Now我的問題是,當我中的index.html的第一個列表元素上單擊當我點擊它會將用戶重定向到第二page.But在第二頁的下一個按鈕,它應該會在第三頁,但沒有任何反應。面臨jquerymobile的多頁面模板stucture問題

這裏是對的index.html: -

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Page Title</title> 

    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> 
    <script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script> 

</head> 
<body> 

<!-- Start of first page --> 
<div data-role="page" id="foo"> 

    <div data-role="header"> 
     <h1>Beginning Android3</h1> 
    </div><!-- /header --> 

    <div data-role="content"> 

     <ul data-role="listview" data-inset="true" data-filter="true" data-divider-theme="e"> 

      <li data-role="list-divider">Part 1:-Core Concept</li> 
      <li><a href="chapter1.html">1:-The Big Picture</a> </li> 
      <li><a href="#">2:-How to Get Started</a></li> 
      <li><a href="#">3:-Your First Android Project</a></li> 
      <li><a href="#">4:-Examining Your First Project</a></li> 

      <li data-role="list-divider">Part 2:-Activities</li> 
      <li><a href="#">5:-Rewriting Your First Project</a></li> 
      <li><a href="#">6:-Using XML-Based Layouts</a></li> 
      <li><a href="#">7:-Employing Basic Widgets</a></li> 

      <li data-role="list-divider">Part 3:-Data Stores, Network Services, and APIs</li> 
      <li><a href="#">8:-Using Preferences</a></li> 
      <li><a href="#">9:-Managing and Accessing Local Databases</a></li> 
      <li><a href="#">10:-Communicating via the Internet</a></li> 
     </ul> 
    </div><!-- /content --> 
    </div> 

</body> 
</html> 

,這裏是第二頁: -

<!DOCTYPE html> 

<html> 

<head> 

<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" /> 
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script> 

</head> 

<body> 

<div data-role="page" data-theme="b" id="page1"> 

    <div data-role="header"> 
     <h1>The Big Picture</h1> 
     <a data-rel="back" data-role="button" data-icon="back" data-theme="a">Back</a> 
     <a href="#page2" data-role="button" data-icon="forward" data-theme="a">Next</a> 
    </div><!-- /header --> 

    <div data-role="content"> 

    <p>Android is everywhere. Phones. Tablets. 
     TVs and set-top boxes powered by Google TV.Soon, 
     Android will be in cars and all sort of other places as well. 
     However, the general theme of Android devices will be smaller 
     screens and/or no hardware keyboard. 
     </p> 

    </div> 

    </div> 



    <div data-role="page" data-theme="b" id="page2"> 

    <div data-role="header"> 
     <h1>The Big Picture</h1> 
     <a data-rel="back" data-role="button" data-icon="back" data-theme="a">Back</a> 
     <a href="#" data-role="button" data-icon="forward" data-theme="a">Next</a> 
    </div><!-- /header --> 


    <div data-role="content"> 

    This is a sample about page. 

    </div> 

    </div> 

    </body> 

    </html> 

IM使用第二page.In第二頁的多頁的技術,我有兩個帶ID的頁面page1 and page2。我無法重定向page2 from page1的上header.Help下一步按鈕我擺脫這些problem.Thanx提前。

回答

6

如果您鏈接到從單頁多頁,您需要設置數據阿賈克斯=「假」:

<li><a data-ajax="false" href="chapter1.html">1:-The Big Picture</a> </li> 
+0

感謝名單哥們它爲我工作... – himanshu 2012-02-21 10:21:50

+0

你的答案是正確的。現在我的下一個按鈕工作正常,但現在我有一個新的問題,添加數據後 - ajax =「false」我的背不工作,你可以告訴爲什麼發生這種情況,是它的解決方案... – himanshu 2012-02-21 10:38:47

+0

而不是data-rel =「back」做href =「index.html」,我假設做一個data-ajax =「false」你會失去y我們的歷史。 – gmh04 2012-02-21 10:50:35

0

我有同樣的問題之前,我結束了使用多頁的解決方案。因爲我需要返回按鈕才能工作。只要我開始使用單個頁面(data-ajax =「false」)。我的歷史記錄會混亂,後退按鈕無法正常工作。 即使我用

<a href="index.html">Back</a> 

(我的後退按鈕),中的index.html將無法正常工作。所以我放棄了,並把所有內容放在索引頁上。

0

一種其他的方式來做到這一點是使用rel="external"如下:

<a href="multipage.html" rel="external" >Multi-page link</a> 

一個完整的教程可以在jQuery Mobile and multiple pages找到

3

感謝@ ghm04給了線索:

<li><a data-ajax="false" href="chapter1.html">1:-The Big Picture</a> </li> 

如果有人想知道爲什麼(至少,我這樣做),答案在文檔中:

請務必注意,如果您從通過Ajax加載的移動頁面鏈接到包含多個內部頁面的頁面,則需要將rel =「external」或data-ajax =「false」添加到鏈接。這告訴框架做一個完整的頁面重載來清除在URL中的Ajax哈希值。因爲Ajax的頁面使用hash(#)跟蹤Ajax的歷史,而多個內部頁面使用hash來表示內部頁面所以會有這兩種模式之間的衝突哈希這一點至關重要。

例如,鏈接到包含多個內部頁面看起來像這樣的頁面: 多頁的鏈接

http://jquerymobile.com/demos/1.0/docs/pages/page-links.html(「多頁文檔內鏈接」)