I have a simple function that changes the page after login. Once the page is changed I want to run a different function to load a map.
function doLogin(username, password){
show_load("logging in...");
Parse.User.logIn(username, password, {
success: function(user){
window.localStorage.setItem("userObjectId", user.objectid);
hide_load();
$.mobile.changePage("home.html", {transition: "slide"}, true, true);
$("#home_page").on("pageshow", function(){
navigator.notification.alert("hello");
});
},
error: function(user, error){
hide_load();
$(".error_popup_title").text("login error");
$(".error_popup_content").text(error.message);
$("#error_popup_link").click();
}
});
}
Right after it changes the page I want to run a function call showMap();
No matter what I do I can't get anything to run after I call the change page. Not even an alert!
I have a simple function that changes the page after login. Once the page is changed I want to run a different function to load a map.
function doLogin(username, password){
show_load("logging in...");
Parse.User.logIn(username, password, {
success: function(user){
window.localStorage.setItem("userObjectId", user.objectid);
hide_load();
$.mobile.changePage("home.html", {transition: "slide"}, true, true);
$("#home_page").on("pageshow", function(){
navigator.notification.alert("hello");
});
},
error: function(user, error){
hide_load();
$(".error_popup_title").text("login error");
$(".error_popup_content").text(error.message);
$("#error_popup_link").click();
}
});
}
Right after it changes the page I want to run a function call showMap();
No matter what I do I can't get anything to run after I call the change page. Not even an alert!
Share Improve this question edited Apr 27, 2014 at 12:19 Muath 4,42712 gold badges44 silver badges70 bronze badges asked Jun 18, 2013 at 21:19 Joe GregJoe Greg 971 silver badge6 bronze badges1 Answer
Reset to default 5you can use on show page event like this:
$("#page_id").on("pageshow" , function() {
showMap();
});