Reputation: 8101
I'm working on a jQuery page and I want to know if the page was reached via the user's "back" button (the one in jQuery mobile (data-rel="back"
), not the browser back button).
I have done a bit of web searching and reading through jqm's site, but no joy.
Upvotes: 2
Views: 97
Reputation: 206151
Try with the callback state.direction
$(window).on("navigate", function (evt, data) {
var backForw = data.state.direction;
if (backForw) {
console.log("Button "+ backForw +" was used");
}
});
Or, if you want you can store a flag into localStorage
and check for it's existence or using JS's pushState
...
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage
https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history
Upvotes: 1