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

Commit

Permalink
Pagecontainer: send samePage param to pagehide event so page widget c…
Browse files Browse the repository at this point in the history
…an check this and not remove page if true Fixes #4078 - Page receives display:none after samePageTransition
  • Loading branch information
arschmitz authored and gseguin committed Nov 15, 2013
1 parent db19668 commit bf339aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
16 changes: 10 additions & 6 deletions js/widgets/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});
}
Expand Down
10 changes: 9 additions & 1 deletion js/widgets/pagecontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf339aa

Please sign in to comment.