android - remember last page in jquery mobile -


i making jquery mobile app phonegap turorial in how read quran want keep progress user nad made , resume when reopen or clue?

you can store last page visited in cookie , redirect after app loads

demo -- visit page re-click run

https://jsfiddle.net/ldgz38s4/

code

//check if lastpage exists , redirect page  if ($.cookie('lastpage')) { $( ":mobile-pagecontainer" ).pagecontainer( "change", "#"+$.cookie('lastpage'))     }   //store page visited in cookie  $(document).on("pageshow", function (e, data) {  var pageid = $.mobile.pagecontainer.pagecontainer( 'getactivepage' ).attr( 'id' );   $.cookie('lastpage', pageid)   }); 

you need include jquery cookie plugging cookies work

https://github.com/carhartl/jquery-cookie

ahh realized using cordova , may have issues storing cookies in android webview. if , above code(setting , reading cookie) doesn't work

check here on how enable local storage instead android webview

android webview & localstorage'

and here on how store , read data within app, easy

http://www.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -