jquery mobile $ .mobile.changePage()Windows phone 8无法工作Cordova / PhoneGap

代码Index.html

First Page

Or through a basic link

和我的js文件

  $(document).on('tap', "#changePage",function () { $.mobile.changePage('https://stackoverflow.com/questions/19009529/jquery-mobile-mobile-changepage-windows-phone-8-not-working-cordova-phonegap/second.html', { reloadPage : false, changeHash : true }); }); 

和https://stackoverflow.com/questions/19009529/jquery-mobile-mobile-changepage-windows-phone-8-not-working-cordova-phonegap/second.html

 

Second Page

click me
change Page

所有这些文件都使用PhoneGap / Cordova打包并在设备上运行。

基本上我试图通过绑定到我的JS文件中的ID #changePage,在tap事件上使用$ .mobile.changePage(“https://stackoverflow.com/questions/19009529/jquery-mobile-mobile-changepage-windows-phone-8-not-working-cordova-phonegap/second.html”)将https://stackoverflow.com/questions/19009529/jquery-mobile-mobile-changepage-windows-phone-8-not-working-cordova-phonegap/second.html加载到index.html页面。

这完全正常

  • Android手机

  • Internet Explorer 9和10

  • Webkit浏览器

但问题是上面的代码不适用于Windows Phone 8

我正在测试的设备是使用的诺基亚Lumia 920 Jquery框架

  • jquery.mobile-1.3.2.js

  • jQuery的2.0.3.js

我也尝试使用$ .ajax作为dataType:“html”和$ .load函数所有这些在上面提到的其他环境中工作得很好,除了Window Phone 8(上面提到的设备)

我也跟着这个

适用于Window手机的StackOverflow解决方案

什么都行不通!!!!!

 var url = window.location.href; url = url.split('#').pop().split('?').pop(); url = url.replace(url.substring(url.lastIndexOf('/') + 1),"second.html"); $.mobile.changePage(url, { reloadPage : false, changeHash : false }); 

我使用了OMAR jquery 1.9.1建议的Jquery。 并且在将URL传递给移动更改页面之前仍需要解析URL。 上面的代码工作得非常好。

上面的代码仍然不适用于Jquery 2.0+,而是使用1.9.x版本! –

我的建议是不要在Windows Phone上使用jquery 2.0+

它不适用于Window Phone,包括$ .ajax,$ .load,$ .get等Ajax调用

前几天我遇到了同样的问题。 $.mobile.changePage('second.html', { reloadPage : false, changeHash : true }); changeHash必须设置为false $.mobile.changePage('second.html', { reloadPage : false, changeHash : true });

旧的Android设备上存在类似的问题。

@ Nirus的解决方案就像以下环境中的魅力一样:

  • jQuery 1.9.1
  • jQM 1.3.2
  • Phonegap 3.5.0-0.21.14
  • Windows Phone 8.1

我希望Phonegap或jQM的团队能在不久的将来解决这个问题。

我刚开始工作的有点类似于@conor的回答。 也许尝试使用页面css id作为选择器。

使用jquery mobile 1.3

jQuery的:

 $(document).ready(function () { $(".myinfo").on("tap", function(){ $.mobile.changePage("#MyInfo", { transition: "none", reverse: false, changeHash: true}); }); 

HTML:

  

链接:

  
  • My Info