2

I'm making jquery mobile app and have one problem. I have three pages:

  • main page with category clicks
  • page with itemlist and category filter.
  • page with item details

when I click category on main page I go to second page with modified select button and filtered list. after clicking item and using history button everything is ok - right category is selected. Problem is when I want to on a second page change category. After clicking item and going back in history I go back to first category not previously changed one. Is there a way to detect wheather back button was used??

piernik
  • 3,507
  • 3
  • 42
  • 84

3 Answers3

2
$(window).on("navigate", function (event, data) {
  var direction = data.state.direction;
  if (direction == 'back') {
    // do something
    localStorage.back=1;
  }
});

did the trick.

piernik
  • 3,507
  • 3
  • 42
  • 84
0

You can cache a page using:

 <div data-role="page" data-dom-cache="true">

or intercept the back button action with:

 jQuery.mobile.navigate( url [, data ] )

http://api.jquerymobile.com/jQuery.mobile.navigate/

grigno
  • 3,128
  • 4
  • 35
  • 47
-2

use this:

window.history.go(-2);
danny.hu
  • 110
  • 3