Good option of stored page id
by Alin Guta
HTML
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<!--1-->
<div data-role="page" id="firstpage">
<div data-role="main" class="ui-content">
<h1>Page 1</h1>
<a href="#secondpage" data-role="button">Store and next</a>
<a href="#firstmage" id="resume" data-role="button">Continue</a>
</div>
</div>
<!--2-->
<div data-role="page" id="secondpage">
<div data-role="main" class="ui-content">
<h1>Page 2</h1>
<a href="#thirdpage" data-role="button">Store and next</a>
<a href="#firstpage" data-role="button">Back to page 1</a>
</div>
</div>
<!--3-->
<div data-role="page" id="thirdpage">
<div data-role="main" class="ui-content">
<h1>Page 3</h1>
<a href="#fourthpage" data-role="button">Store and next</a>
<a href="#firstpage" data-role="button">Back to page 1</a>
</div>
</div>
<!--4-->
<div data-role="page" id="fourthpage">
<div data-role="main" class="ui-content">
<h1>Page 4</h1>
<a href="#" data-role="button">Store</a>
<a href="#firstpage" data-role="button">Back to page 1</a>
</div>
</div>
JavaScript
$(document).on("pagecontainerhide", function (e, data) {
var stored = data.prevPage.attr('id');
console.log(stored);
localStorage.setItem('stored', stored);
}).on("pagecontainershow", function (e, data) {
if (data.toPage[0].id == "firstpage") {
var test = localStorage.getItem('stored');
var resume = "#" + test;
$("#resume").attr("href", resume);
if (test == "firstpage") {
$("#resume").hide();
} else {
$("#resume").fadeIn();
}
}
});