Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

loadPage: update to account for if the page is prefetched done update…

… basetag. Fixed #5677 - Navigation: Prefetching pages from other directories offsets <base>-tag

(cherry picked from commit be22887)
  • Loading branch information...
commit c8a80465daf562c14eff8c63988757dbe998e2bd 1 parent 5b1731a
@arschmitz arschmitz authored gabrielschulhof committed
Showing with 11 additions and 7 deletions.
  1. +11 −7 js/jquery.mobile.navigation.js
View
18 js/jquery.mobile.navigation.js
@@ -430,6 +430,7 @@ define( [
.jqmData( "url", dataUrl );
}
+
// If we failed to find a page in the DOM, check the URL to see if it
// refers to the first page in the application. If it isn't a reference
// to the first page and refers to non-existent embedded page, error out.
@@ -451,7 +452,7 @@ define( [
return deferred.promise();
}
}
-
+
// If the page we are interested in is already in the DOM,
// and the caller did not indicate that we should force a
// reload of the file, we are done. Otherwise, track the
@@ -460,11 +461,14 @@ define( [
if ( !settings.reloadPage ) {
enhancePage( page, settings.role );
deferred.resolve( absUrl, options, page );
+ //if we are reloading the page make sure we update the base if its not a prefetch
+ if( base && !options.prefetch ){
+ base.set(url);
+ }
return deferred.promise();
}
dupCachedPage = page;
}
-
var mpc = settings.pageContainer,
pblEvent = new $.Event( "pagebeforeload" ),
triggerData = { url: url, absUrl: absUrl, dataUrl: dataUrl, deferred: deferred, options: settings };
@@ -494,9 +498,9 @@ define( [
$.mobile.hidePageLoadingMsg();
};
}
-
// Reset base to the default document base.
- if ( base ) {
+ // only reset if we are not prefetching
+ if ( base && typeof options.prefetch === "undefined" ) {
base.reset();
}
@@ -530,8 +534,8 @@ define( [
RegExp.$1 ) {
url = fileUrl = path.getFilePath( $( "<div>" + RegExp.$1 + "</div>" ).text() );
}
-
- if ( base ) {
+ //dont update the base tag if we are prefetching
+ if ( base && typeof options.prefetch === "undefined") {
base.set( fileUrl );
}
@@ -1251,7 +1255,7 @@ define( [
if ( url && $.inArray( url, urls ) === -1 ) {
urls.push( url );
- $.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ) } );
+ $.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } );
}
});
});

1 comment on commit c8a8046

@evilripper

I have some problem with the prefetch option: in my code I load some page created dynamically but now in firefox I get this error
TypeError: options is undefined
in chrome the same
TypeError: Cannot read property 'prefetch' of undefined
if i set the option on loadPage("#shajshs", true) it works! O_o
example code:
http://jsfiddle.net/evilripper/d5eK6/1/

Please sign in to comment.
Something went wrong with that request. Please try again.