Permalink
Browse files

Pagecontainer: Honor both reload and reloadPage during load

Option reload takes precedence over option reloadPage

(cherry picked from commit 5f622de)

Closes gh-7801
Fixes gh-7769
  • Loading branch information...
gabrielschulhof committed Oct 25, 2014
1 parent 198e5d2 commit 7b97a67a0d7b95c0ff09869a5baaee4e274fc50d
Showing with 34 additions and 6 deletions.
  1. +9 −4 js/widgets/pagecontainer.js
  2. +25 −2 tests/unit/pagecontainer/pagecontainer_core.js
@@ -587,8 +587,16 @@ define( [
// know when the content is done loading, or if an error has occurred.
var deferred = ( options && options.deferred ) || $.Deferred(),
// Examining the option "reloadPage" passed by the user is deprecated as of 1.4.0
// and will be removed in 1.5.0.
// Copy option "reloadPage" to "reload", but only if option "reload" is not present
reloadOptionExtension =
( ( options && options.reload === undefined &&
options.reloadPage !== undefined ) ?
{ reload: options.reloadPage } : {} ),
// The default load options with overrides specified by the caller.
settings = $.extend( {}, this._loadDefaults, options ),
settings = $.extend( {}, this._loadDefaults, options, reloadOptionExtension ),
// The DOM element for the content after it has been loaded.
content = null,
@@ -598,9 +606,6 @@ define( [
absUrl = $.mobile.path.makeUrlAbsolute( url, this._findBaseWithDefault() ),
fileUrl, dataUrl, pblEvent, triggerData;
// DEPRECATED reloadPage
settings.reload = settings.reloadPage;
// If the caller provided data, and we're using "get" request,
// append the data to the URL.
if ( settings.data && settings.type === "get" ) {
@@ -13,10 +13,12 @@ test( "_find() can handle weird data-url attributes", function() {
});
( function() {
var originalLoad = $.mobile.pagecontainer.prototype._triggerWithDeprecated
var triggerData,
originalLoad = $.mobile.pagecontainer.prototype._triggerWithDeprecated;
module( "load method", {
setup: function(){
$.mobile.pagecontainer.prototype._triggerWithDeprecated = function(){
$.mobile.pagecontainer.prototype._triggerWithDeprecated = function( eventName, data ) {
triggerData = data;
return {
deprecatedEvent: {
isDefaultPrevented: function() {
@@ -30,6 +32,7 @@ module( "load method", {
}
},
teardown: function(){
triggerData = null;
$.mobile.pagecontainer.prototype._triggerWithDeprecated = originalLoad;
}
});
@@ -40,6 +43,26 @@ test( "load does not trigger an error when called withput a second param", funct
ok( "no error triggered when load method called without options" );
});
test( "Options 'reload' and 'reloadPage' both work, and 'reload' takes precedence", function() {
var pagecontainer = $( ":mobile-pagecontainer" );
pagecontainer.pagecontainer( "load", "stuff.html", {
reload: true,
reloadPage: false
});
deepEqual( triggerData.options.reload, true,
"The value of option 'reload' is not affected by the value of option 'reloadPage'" );
pagecontainer.pagecontainer( "load", "stuff.html", {
reloadPage: true
});
deepEqual( triggerData.options.reload, true,
"The value of option 'reloadPage' is copied to the value of option 'reload' if the " +
"latter is absent from the options hash" );
});
module( "_handleDialog()" );
test( "A dialog is recognized via presence of the data key, not the ui-dialog class", function() {

0 comments on commit 7b97a67

Please sign in to comment.