I am making a jquery mobile app With phonegap It is like a turorial in how to read Quran I want it to keep the progress the user nad made and resume it when reopen Any help or clue?
Asked
Active
Viewed 110 times
1 Answers
1
You can Store the last page visited in a cookie and redirect to that after the app loads
Demo -- visit a page re-click run
https://jsfiddle.net/Ldgz38s4/
Code
//check if the lastpage exists and redirect to the page
if ($.cookie('lastpage')) {
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#"+$.cookie('lastpage'))
}
//store the page visited in a cookie
$(document).on("pageshow", function (e, data) {
var pageid = $.mobile.pageContainer.pagecontainer( 'getActivePage' ).attr( 'id' );
$.cookie('lastpage', pageid)
});
you need include the Jquery cookie plugging for cookies to work
https://github.com/carhartl/jquery-cookie
ahh just realized you are using Cordova and may have issues with storing cookies in Android webview. If you do and the above code(setting and reading the cookie) doesn't work then
Check here on how to enable local storage instead for Android webview
Android webview & localStorage'
and here on how to store and read data within the App, its easy
http://www.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/