且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-10-17 12:07:04

  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

*** 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