From bf339aac29f146fc703d37c271ef1270432c456f Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 2 Oct 2013 12:13:43 -0400 Subject: [PATCH] Pagecontainer: send samePage param to pagehide event so page widget can check this and not remove page if true Fixes #4078 - Page receives display:none after samePageTransition --- js/widgets/page.js | 16 ++++++++++------ js/widgets/pagecontainer.js | 10 +++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) 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