Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit d7dc1f3

Browse files
committed
fix for pagechange value and test of 3 page change events
1 parent 9b6cd5b commit d7dc1f3

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

js/jquery.mobile.navigation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,8 @@ define( [
10301030
options.duplicateCachedPage = dupCachedPage;
10311031

10321032
// store the original absolute url so that it can be provided
1033-
// to events in the triggerData
1034-
newPage.data( 'absUrl', triggerData.url );
1033+
// to events in the triggerData of the subsequent changePage call
1034+
newPage.data( 'absUrl', triggerData.absUrl );
10351035
$.mobile.changePage( newPage, options );
10361036
})
10371037
.fail(function( url, options ) {

tests/unit/navigation/navigation_core.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,4 +1312,33 @@
13121312
}
13131313
]);
13141314
});
1315+
1316+
1317+
var absHomeUrl = $.mobile.path.parseLocation().hrefNoHash,
1318+
homeDomain = $.mobile.path.parseLocation().domain;
1319+
1320+
asyncTest( "page load events are providided with the absolute url for the content", function() {
1321+
var requestPath;
1322+
1323+
expect( 3 );
1324+
1325+
$( document ).one( "pagebeforechange", function( event, data ) {
1326+
equal( data.absUrl, absHomeUrl + "#bar");
1327+
});
1328+
1329+
$( document ).one( "pagechange", function( event, data ) {
1330+
equal( data.absUrl, absHomeUrl + "#bar" );
1331+
});
1332+
1333+
$.mobile.changePage( "#bar" );
1334+
1335+
requestPath = "/theres/no/way/this/page/exists.html";
1336+
1337+
$( document ).one( "pagechangefailed", function( event, data ) {
1338+
equal( data.absUrl, homeDomain + requestPath );
1339+
start();
1340+
});
1341+
1342+
$.mobile.changePage( requestPath );
1343+
});
13151344
})(jQuery);

0 commit comments

Comments
 (0)