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

Commit 6cd1e1b

Browse files
committed
Fix for issue 2529 - Transition to the same page
- Added a new allowSamePageTransition option to the changePage() method default settings. By default, we prevent changePage() requests when the fromPage and toPage are the same element, but folks that generate content manually/dynamically and reuse pages want to be able to transition to the same page. To allow this, they will need to change the default value of allowSamePageTransition to true, *OR*, pass it in as an option when they manually call changePage(). It should be noted that our default transition animations assume that the formPage and toPage are different elements, so they may behave unexpectedly. It is up to the developer that turns on the allowSamePageTransitiona option to either turn off transition animations, or make sure that an appropriate animation transition is used. // To toggle the default behavior for all changePage() calls, // set the default value of allowSamePageTransition to whatever // you want it to be. The default is false. $.mobile.changePage.defaults.allowSamePageTransition = true; // To specify the behavior when manually calling changePage(), // pass it as an option. If not specified, the default value // specified by $.mobile.changepage.defaults.allowSamePageTransition // is used. $.mobile.changePage( "#reused-page", { allowSamePageTransition: true } );
1 parent 86ab894 commit 6cd1e1b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

js/jquery.mobile.navigation.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,17 @@
10231023
pageTitle = document.title,
10241024
isDialog = settings.role === "dialog" || toPage.jqmData( "role" ) === "dialog";
10251025

1026-
// If we are trying to transition to the same page that we are currently on ignore the request.
1027-
// an illegal same page request is defined by the current page being the same as the url, as long as there's history
1028-
// and toPage is not an array or object (those are allowed to be "same")
1029-
//
1030-
// XXX_jblas: We need to remove this at some point when we allow for transitions
1031-
// to the same page.
1032-
if( fromPage && fromPage[0] === toPage[0] ) {
1026+
// By default, we prevent changePage requests when the fromPage and toPage
1027+
// are the same element, but folks that generate content manually/dynamically
1028+
// and reuse pages want to be able to transition to the same page. To allow
1029+
// this, they will need to change the default value of allowSamePageTransition
1030+
// to true, *OR*, pass it in as an option when they manually call changePage().
1031+
// It should be noted that our default transition animations assume that the
1032+
// formPage and toPage are different elements, so they may behave unexpectedly.
1033+
// It is up to the developer that turns on the allowSamePageTransitiona option
1034+
// to either turn off transition animations, or make sure that an appropriate
1035+
// animation transition is used.
1036+
if( fromPage && fromPage[0] === toPage[0] && !settings.allowSamePageTransition ) {
10331037
isPageTransitioning = false;
10341038
mpc.trigger( "pagechange", triggerData );
10351039
return;
@@ -1132,7 +1136,8 @@
11321136
pageContainer: undefined,
11331137
showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage
11341138
dataUrl: undefined,
1135-
fromPage: undefined
1139+
fromPage: undefined,
1140+
allowSamePageTransition: false
11361141
};
11371142

11381143
/* Event Bindings - hashchange, submit, and click */

0 commit comments

Comments
 (0)