2012-07-25 81 views
1

嗨,從一個頁面導航到另一個我用$.mobile.changePage('test.html');。這在Android,symbian和blackberry6 +中工作正常。但我也希望我的應用程序能夠在blackberry5上運行。 Blackberry5不支持AJAX,因此$.mobile.changePage('test.html');不適用於它。

因此,我使用window.open("test.html");window.location.href = "test.html";在這裏它可以在所有平臺(包括blackberry4.6 +)都能很好地工作。但現在的問題是我在test.html標題爲:

 <div data-role="header" align="center"> 

     <a href="#" data-rel="back" data-icon="arrow-l">Back</a> 
      <h1>Test.html</h1> 
     <a href="MainMenu.html" data-icon="grid">Menu</a> 


    </div> 

但現在這裏後退按鈕不工作。如果我使用$.mobile.changePage('test.html');進行導航,則後退按鈕可以很好地工作,但不適用於window.open("test.html");window.location.href = "test.html";

因此,我使用會話和點擊後退按鈕,我強烈地打電話給頁面。如:

<script type="application/javascript"> 

      function redirect(url) 
      { 
       alert("inside redirect:"+url); 
       window.location = url; 
      } 

     </script> 

     <div data-role="navbar"> 
      <ul> 

       <li> <a onclick="redirect(getCookie('paged'))" data-icon="back" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Back</a></li> 
       <li> <a onclick="redirect(getCookie('paged'))" data-icon="back" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Back</a></li> 

      </ul> 
     </div> 

這裏現在後退按鈕也完美的作品,但是當我點擊硬件後退按鈕,然後再次去從它原來的地方前幾頁。

如何使用$.mobile.changePage(...)沒有Ajax,所以我可以將它用於所有平臺,包括blackberry4.6 +

任何建議將不勝感激。提前致謝。

回答

0

您是否嘗試過將全局屬性$.mobile.ajaxEnabled設置爲false?見http://jquerymobile.com/demos/1.1.1/docs/api/globalconfig.html。據寫道,「如有可能,jQuery Mobile將自動處理鏈接點擊並通過Ajax提交表單」。我不確定它現在是否也會影響$.mobile.changePage,但也許值得一試...

+1

我試着用「$。 mobile.ajaxEnabled = false; \t \t \t'但沒有運氣。感謝您的建議。 – PPD 2012-07-25 06:39:16

0

您可以使用此功能。

$.mobile.changePage('#gototestpage'); 

但是有一些限制。你將不得不保持同一頁面的代碼在另一個DIV像這樣,

<div id="gototestpage"> --- Your Code here ----- </div> 
+0

Blackberry5不支持ajax,因此我不能使用$ .mobile.changePage。 – PPD 2012-07-25 13:05:06

1

我嘗試使用全局配置禁用AJAX,但它並沒有爲我工作了一段原因。

我嘗試如下,它的工作

window.location.href="myfile.html"; 
0

我已經試過這兩種解決方案,都爲我工作:

window.location.href = yourpageurl; 

$.mobile.ajaxEnabled = false; 
$(":mobile-pagecontainer").pagecontainer("change", yourpageurl);