Joe Greg
Joe Greg

Reputation: 97

Jquery Mobile call function after change page

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!

Upvotes: 2

Views: 5254

Answers (1)

Muath
Muath

Reputation: 4417

you can use on show page event like this:

$("#page_id").on("pageshow" , function() {
  showMap();
});

Upvotes: 5

Related Questions