jquery mobile $ .mobile.changePage()Windows phone 8不工作Cordova / PhoneGap [英] jquery mobile $.mobile.changePage() Windows phone 8 not working Cordova/PhoneGap

查看:251
本文介绍了jquery mobile $ .mobile.changePage()Windows phone 8不工作Cordova / PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码Index.html

 < div data-role =pageid =index> 
< div data-role =header>
< h3>
首页
< / h3>
< / div>
< div id =data>

< / div>
< div data-role =content>
< button data-role =buttonid =changePage>使用changePage函数传递参数< / button>
< a href =second.htmldata-role =button>或通过基本链接< / a>
< / div>
< / div>

和我的js档案

  $(document).on('tap',#changePage,function(){
$ .mobile.changePage('second.html',{reloadPage:false,changeHash: true});
});

和second.html

 < div data-role =pageid =second> 
< div data-role =header>
< h3>
第二页
< / h3>
< / div>
< div data-role =content>
< div id =data>< / div>
< div data-role =buttonid =clickBtn>点击我< / div>
< div data-role =buttonid =paqeBtn> change Page< / div>
< / div>
< / div>

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



基本上,我试图通过绑定到我的JS文件中的ID #changePage,通过点击事件使用$ .mobile.changePage(second.html)加载second.html到index.html页面。



这在

中完美无缺。


  • Android手机


  • Internet Explorer 9和10


  • Webkit浏览器

    b $ b


但问题是上面的代码不能在Windows Phone 8上工作



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




  • jquery.mobile -1.3.2.js


  • jquery-2.0.3.js




我也试过$ .ajax作为dataType:html和$ .load函数所有这些工作完全正常在上面提到的除了Window Phone 8(上面提到的设备)



我也遵循了



StackOverflow解决方案的Window手机



没有什么工作!!!!!

解决方案

  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,然后将其传递到移动更改页面。上面的代码工作完全正常。



上面的代码仍然不能用于Jquery 2.0+,而改用1.9.x版本!
-



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



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


code Index.html

<div data-role="page" id="index">
    <div data-role="header">
        <h3>
            First Page
        </h3>
    </div>
    <div id="data">

    </div>
    <div data-role="content">
        <button data-role="button" id="changePage">Pass parameters with changePage function</button>
        <a href="second.html"  data-role="button">Or through a basic link</a>
    </div>
</div>

and My js file

 $(document).on('tap', "#changePage",function () {     
              $.mobile.changePage('second.html', { reloadPage : false, changeHash : true });
    }); 

and the second.html

<div data-role="page" id="second">
    <div data-role="header">
        <h3>
            Second Page
        </h3>
    </div>
    <div data-role="content">
<div id="data"></div>
    <div data-role="button" id="clickBtn">click me</div>
    <div data-role="button" id="paqeBtn">change Page</div>
  </div>
 </div>

All these files are packaged using PhoneGap/Cordova and run on the device.

Basically i am trying to load second.html into index.html page using $.mobile.changePage("second.html") on tap event by binding to the ID #changePage in my JS file.

This is perfectly working fine in

  • Android phones

  • Internet Explorer 9 and 10

  • Webkit Browsers

But the problem is the above code is not working on Windows Phone 8

The device i am testing on is Nokia Lumia 920 Jquery framework used is

  • jquery.mobile-1.3.2.js

  • jquery-2.0.3.js

i also tried with $.ajax as dataType:"html" and $.load functions all these worked perfectly fine in other environment mentioned above except in Window Phone 8 (device mentioned above)

I also followed this

StackOverflow solution for Window phones

nothing worked!!!!!

解决方案

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 });

I used the Jquery suggested by OMAR jquery 1.9.1. and but still need to parse the URL before passing it to mobile change page. The above code worked perfectly fine.

The above code still will not work for Jquery 2.0+, use the 1.9.x version instead!! -

My suggestion is not to use jquery 2.0+ for Windows Phones

It will not work for Window Phone's including Ajax call like $.ajax, $.load, $.get

这篇关于jquery mobile $ .mobile.changePage()Windows phone 8不工作Cordova / PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆