Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
602 views
in Technique[技术] by (71.8m points)

cordova - jQuery Mobile changePage() not working in Windows Phone

I am developing an application using Phonegap for Windows Phone 8.

I've used jQuery Mobile for interface design.

the $.mobile.changePage() is not working. The page is not being changed.

Is there any other way to change the page? Is there any other framework to design the interface for mobile?

$("#btnSearch").bind('click', function() {
    showSpinner();
    $.mobile.changePage("#pageSearch");
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think this problem is the same as in WP7 described here.

CHECK FOR PATH PROBLEM:

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:

As described in github, problem is path on WP7 differs from other platforms. Basically on WP7 getLocation prints relative paths with double slashes, which causes this issue at first place. To fix, open jquery.mobile-1.3.1.js and refactor following:

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

and:

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

After making this changes, check should display "everything is OK".

PS This is tested on WP7 and totally fixed my issue with $.mobile.changePage().

PS2 This issue is fixed at github version of jQuery, although I've just checked latest stable version(1.3.2) and unfortunately it is NOT fixed there.

Regards,

Hristo Todorov


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...