I need to use this
jQuery( ".selector" ).on( "pagebeforechange", function( event ) { ... } )
to check my local storage key / value to decide which screen to load. I have read this document but I'm new to Javascript and do not understand how to execute this correctly.
The documentation does not show any example code.
I have also tried a few methods found on Stackoverflow but they didn't work at all.
Please show some example code. Thank you.
Lesz
Code update:
//Check localStorage
$(document).bind('pagebeforechange', function (event, ui) {
if(localStorage.logon == "yes")
$.mobile.changePage("#userMainPage");
else
$.mobile.changePage("#welcome");
});
Code using this post as reference as suggested by @Omar
//Check localStorage
$(document).on("pagebeforechange", function(e, data) {
if (localStorage.logon == "yes") {
$.mobile.changePage("#userMainPage", {
transition: "flow"
});
e.preventDefault();
}
});
Both code doesn't not bring me to the page as it should.