Phonegap jqm mixing local and server html files
Posted
by
DavidVdd
on Stack Overflow
See other posts from Stack Overflow
or by DavidVdd
Published on 2014-06-04T15:22:22Z
Indexed on
2014/06/04
15:24 UTC
Read the original article
Hit count: 238
jquery-mobile
|cordova
I would like to add some online pages to an application keep them up to date without releasing a new store version. For this I taught I could use jqm ajax navigation to load the external page. (I'm aware that might not be allowed for all platforms.)
I have set:
$.mobile.allowCrossDomainPages = true;
$.mobile.pushStateEnabled = false;
This seems to work but the problem is that all my href's and $.mobile.ChangePages would have to be changed to
<a href='http://mydomain.com/mypage.html'>link</a>
$.mobile.changePage('http://mydomain.com/mypage.html');
in stead of
<a href='mypage.html'>link</a>
$.mobile.changePage('http://mydomain.com/mypage.html');
I was thinking about overriding the changepage method(found this somewhere) to add a domain when the user is online, but the problem is that this method get's called more then once.
var originalChangePage = $.mobile.changePage;
$.mobile.changePage = function(to, options) {
var o = JSON.stringify(o);
try {
to = to.replace('file:///android_asset/www/', 'http://mydomain.com/');
}
catch (err) {
//to isn't always filled in.
}
originalChangePage(to, options);
};
Is there a better way to load html pages locally and online using jqm ajax navigation?
Extra info:
- Phonegap/Cordova version 3.5.0
- jqm 1.3.2
© Stack Overflow or respective owner