2013-03-06 86 views
6

工作,我正在開發使用PhoneGap的Windows Phone的8jQuery Mobile的changePage()無法在Windows手機

我使用jQuery Mobile的界面設計的應用程序。

$.mobile.changePage()不起作用。該頁面未被更改。

是否有任何其他方式更改頁面?有沒有其他的框架來設計移動界面?

$("#btnSearch").bind('click', function() { 
    showSpinner(); 
    $.mobile.changePage("#pageSearch"); 
}); 
+0

您發佈了調用'$ .mobile.changePage()'的代碼嗎? – 2013-03-06 13:42:27

+0

該代碼在Android上完美工作。 – 2013-03-06 13:44:46

+1

jQuery Mobile不支持Windows 8 Mobile版本至當前版本sion,http://jquerymobile.com/gbs/。但是你的代碼是正確的。主要問題是不受支持的操作系統。 – Gajotres 2013-03-06 14:08:41

回答

2

我覺得這個問題是一樣的WP7中描述here

檢查路徑問題:

if($.mobile.path.getLocation("x-wmapp1:/app/www/index.html") != "x-wmapp1:/app/www/index.html") 
{ 
    console.log('there is path problem'); 
} 
else 
{ 
    console.log('everything is OK with paths'); 
} 

SOLUTION:

如github上所述,問題是路徑上WP7從其他平臺不同。基本上在WP7上,getLocation用雙斜線打印相對路徑,這首先導致了這個問題。要修復,開放jquery.mobile-1.3.1.js和重構如下:

-  var uri = url ? this.parseUrl(url) : location, 
-   hash = this.parseUrl(url || location.href).hash; 
+  var uri = this.parseUrl(url || location.href), 
+   hash = uri.hash; 

和:

-  return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash; 
+  return uri.protocol + uri.doubleSlash + uri.host + uri.pathname + uri.search + hash; 

使這一變化,檢查應顯示 「一切正常」 後。

PS這是在WP7上測試和完全解決我的問題$ .mobile.changePage()。

PS2此問題被固定在的jQuery GitHub的版本,雖然我剛剛檢查最新的穩定版本(1.3.2),不幸的是它不是固定在那裏。

問候,

赫里斯託·託多羅夫

+0

Wowza,這個固定的changePage適合我在Windows Phone 8.任何機會這將在1.3.3或os? – 2013-08-11 06:03:43

1

我確實有在上面的答覆中提到的路徑問題,但這並沒有解決我的問題。經過大量的試驗和錯誤,我發現它是導致問題的URL開始處的協議。

爲「的mypage.html」改變頁面會發送一個Ajax請求

x-wmapp0://www/mypage.html 

它需要只是

www/mypage.html 

我做了一個modifcation到jQuery Mobile的源操縱字符串來切斷協議,現在它完美地工作。

要應用此修復程序,請在未縮小的 jQuery Mobile js文件中搜索「$。AJAX 「並添加以下只是之前:

var parts = fileUrl.split("www/"); 
fileUrl = "www/" + parts[parts.length-1]; 

這實際上消除 」X-wmapp0:// WWW /「,並提出了 」WWW /「 重新打開刪除而已。」 X-wmapp0:// 「並不總是工作,因爲jQuery Mobile與URL一起工作的方式,導致在某些情況下」www/www/...「

這被證實可以與Cordova 3.1和3.3一起使用jQuery Mobile 1.3.2

+0

非常感謝你對我來說這是一個巨大的痛苦!我需要爲Windows Phone和iOs/Android保留單獨的jQuery移動版本(因爲我沒有問題) – 2013-11-28 13:20:00

+0

我一直在爲我的單獨副本。 – 2014-02-26 15:15:20