Persist a problem, maybe is the wrong function:
$( document ).on( "pagebeforechange", function( event,
ui ) {
initGeolocation();
MAC = getCookie("id_consumer");
time_zone = get_time_zone_offset();
});
This should load exactly after the mobileinit (override global
settings), infact pagebeforechange should run at first after mobile init.
This is the initGeolocation functions:
// GET CURRENT POSITION
function initGeolocation(){
if( navigator.geolocation )
{
// Call getCurrentPosition with
success and failure callbacks
navigator.geolocation.getCurrentPosition( success, fail );
}
else
{
nogps = true;
}
}
function success(position){
latitude = position.coords.latitude;
longitude = position.coords.longitude;
nogps = false;
}
function fail(){
nogps = true;
}
And finally this
$( document ).on( "pagecontainershow", function( event,
ui ) {
if(
nogps == true ){
$(
":mobile-pagecontainer" ).pagecontainer(
"change", "nogps.php" );
}
});
But the problem is that the var nogps is not set to true (i keep
geolocation disactivated for testing). The change page happen only
after i change manually page after the first load.
How should work? Every page change (and first load too) i check if
I can get geolocation of user, if not i send to the "nogps"
page. Can the problem be related to my geolocation function that need
more time to operate?