Permalink
Browse files

Include `$.mobile.forceReverse` to be able to set the 'reverse' direc…

…tion, even when the link binding was disabled. Useful when you're using backbone & jquery mobile, so:

```
$.mobile.forceReverse = true;

($('a[data-rel="back"]')).live('click', function() {
  $.mobile.forceReverse = true;
  window.history.back();
});
```
  • Loading branch information...
1 parent f2b989c commit b6b9a5e194ef1cd9efdfafff4d09264b420bfb6b @mariozaizar committed Aug 28, 2012
Showing with 26 additions and 2 deletions.
  1. +13 −0 docs/pages/page-transitions.html
  2. +11 −1 js/jquery.mobile.core.js
  3. +2 −1 js/jquery.mobile.navigation.js
View
13 docs/pages/page-transitions.html
@@ -111,6 +111,19 @@
<h2>Setting a transition on a link or form submit</h2>
<p>By default, the framework applies a <strong>fade</strong> transition. To set a custom transition effect, add the <code>data-transition</code> attribute to the link. </p>
+ <p>
+ Note that reverse direction won't be applied if you disable the link binding with <code>$.mobile.linkBindingEnabled = false;</code>.
+ If you want to force a reverse direction, please define: <code>$.mobile.forceReverse = true;</code>. For example:
+
+<code>
+$.mobile.forceReverse = true;
+
+($('a[data-rel="back"]')).live('click', function() {
+ $.mobile.forceReverse = true;
+ window.history.back();
+});
+</code>
+ </p>
<code><code>
&lt;a href=&quot;index.html&quot; <strong>data-transition=&quot;pop&quot;</strong>&gt;I'll pop&lt;/a&gt;
View
12 js/jquery.mobile.core.js
@@ -64,9 +64,19 @@ define( [ "jquery", "text!../version.txt" ], function( $, __version__ ) {
// For error messages, which theme does the box uses?
pageLoadErrorMessageTheme: "e",
- //automatically initialize the DOM when it's ready
+ // Automatically initialize the DOM when it's ready
autoInitializePage: true,
+ // Force reverse direction, for example when:
+ // $.mobile.linkBindingEnabled = false;
+
+ // So, you can:
+ // ($('a[data-rel="back"]')).live('click', function() {
+ // $.mobile.forceReverse = true;
+ // window.history.back();
+ // });
+ forceReverse: false,
+
pushStateEnabled: true,
// allows users to opt in to ignoring content by marking a parent element as
View
3 js/jquery.mobile.navigation.js
@@ -1150,7 +1150,8 @@ define( [
$.mobile.activePage = toPage;
// If we're navigating back in the URL history, set reverse accordingly.
- settings.reverse = settings.reverse || historyDir < 0;
+ settings.reverse = settings.reverse || $.mobile.forceReverse || historyDir < 0;
+ $.mobile.forceReverse = false;
transitionPages( toPage, fromPage, settings.transition, settings.reverse )
.done(function( name, reverse, $to, $from, alreadyFocused ) {

0 comments on commit b6b9a5e

Please sign in to comment.