I'm trying to fire and event at the loading of my app: When the app starts, I load the #home page BUT if the user is not cached (I use kinvey), the app should change page to the #login. How can I accomplish that?
I tryied this code at the beginning of myScript.js file, and this is declared at the beginning:
$('#home').on( 'pageshow',function(){
var user = Kinvey.getActiveUser();
var promise = Kinvey.User.me({
success: function(response) {
$.mobile.changePage('#login'); //should change page here
});
}
I would appreciate suggestions on what event to trigger, because there are many in jquerymobile documentation and I don't know which is the more convenient.
try:
Alternatives might include:
If you're using cordova and have enabled the splash page in config you could try: