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

Commit

Permalink
fix for pagechange value and test of 3 page change events
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Oct 12, 2012
1 parent 9b6cd5b commit d7dc1f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/jquery.mobile.navigation.js
Expand Up @@ -1030,8 +1030,8 @@ define( [
options.duplicateCachedPage = dupCachedPage;

// store the original absolute url so that it can be provided
// to events in the triggerData
newPage.data( 'absUrl', triggerData.url );
// to events in the triggerData of the subsequent changePage call
newPage.data( 'absUrl', triggerData.absUrl );
$.mobile.changePage( newPage, options );
})
.fail(function( url, options ) {
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/navigation/navigation_core.js
Expand Up @@ -1312,4 +1312,33 @@
}
]);
});


var absHomeUrl = $.mobile.path.parseLocation().hrefNoHash,
homeDomain = $.mobile.path.parseLocation().domain;

asyncTest( "page load events are providided with the absolute url for the content", function() {
var requestPath;

expect( 3 );

$( document ).one( "pagebeforechange", function( event, data ) {
equal( data.absUrl, absHomeUrl + "#bar");
});

$( document ).one( "pagechange", function( event, data ) {
equal( data.absUrl, absHomeUrl + "#bar" );
});

$.mobile.changePage( "#bar" );

requestPath = "/theres/no/way/this/page/exists.html";

$( document ).one( "pagechangefailed", function( event, data ) {
equal( data.absUrl, homeDomain + requestPath );
start();
});

$.mobile.changePage( requestPath );
});
})(jQuery);

0 comments on commit d7dc1f3

Please sign in to comment.