Be able to use 'reverse' direction, even if you disable back-button handlers (for example when using jqm with backbone.js) #4902

wants to merge 1 commit into


None yet
3 participants

mariozaizar commented Aug 28, 2012


  • jQuery Mobile + backbone.js App.
  • jQuery Mobile bindings/history/routing were disabled to use Backbone's.
  • Back buttons are being used manually (that means using window.history.back directly)


  • 1.1.1 won't apply the reverse direction even if you set the link with data-direction="reverse" to the links.


For example having:
(based on )

  # Disable jQuery Mobile routing and history to use Backbone.
  $.mobile.ajaxEnabled = false
  $.mobile.linkBindingEnabled = false
  $.mobile.hashListeningEnabled = false
  $.mobile.pushStateEnabled = false

  # Enable back buttons by default
  $ = true

This will add the back button, but since all the handlers are disabled, you need to redirect to the last page manually:

($('a[data-rel="back"]')).live('click', function() {

That will work. But sadly you won't see the default reverse direction for any back button. But it will be fixed by setting the $.mobile.forceReverse = true. So letting the application to use forward direction by default, and reverse for all the back buttons.

($('a[data-rel="back"]')).live('click', function() {
  $.mobile.forceReverse = true;

That change won't affect any other place than the Back buttons. And the variable is false by default.
I've included the Documentation changes too.

@mariozaizar mariozaizar 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;

arschmitz commented Aug 6, 2013

this is very old and there are conflicts will be happy to reopen and review if it is updated

arschmitz closed this Aug 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment