diff --git a/js/widgets/page.js b/js/widgets/page.js index d462ef69e68..708301b44da 100644 --- a/js/widgets/page.js +++ b/js/widgets/page.js @@ -110,14 +110,18 @@ $.widget( "mobile.page", { page.is( ":jqmData(external-page='true')" ) ) { // TODO use _on - that is, sort out why it doesn't work in this case - page.bind( "pagehide.remove", callback || function(/* e */) { - var $this = $( this ), - prEvent = new $.Event( "pageremove" ); + page.bind( "pagehide.remove", callback || function( e, data ) { - $this.trigger( prEvent ); + //check if this is a same page transition and if so don't remove the page + if( !data.samePage ){ + var $this = $( this ), + prEvent = new $.Event( "pageremove" ); - if ( !prEvent.isDefaultPrevented() ) { - $this.removeWithDependents(); + $this.trigger( prEvent ); + + if ( !prEvent.isDefaultPrevented() ) { + $this.removeWithDependents(); + } } }); } diff --git a/js/widgets/pagecontainer.js b/js/widgets/pagecontainer.js index 977cdd4136a..dcfd06775d2 100644 --- a/js/widgets/pagecontainer.js +++ b/js/widgets/pagecontainer.js @@ -748,13 +748,21 @@ define( [ // TODO move into transition handlers? _triggerCssTransitionEvents: function( to, from, prefix ) { + var samePage = false; + prefix = prefix || ""; // TODO decide if these events should in fact be triggered on the container if ( from ) { + + //Check if this is a same page transition and tell the handler in page + if( to[0] == from[0] ){ + samePage = true; + } + //trigger before show/hide events // TODO deprecate nextPage in favor of next - this._triggerWithDeprecated( prefix + "hide", { nextPage: to }, from ); + this._triggerWithDeprecated( prefix + "hide", { nextPage: to, samePage: samePage }, from ); } // TODO deprecate prevPage in favor of previous