最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery Mobile call function after change page - Stack Overflow

programmeradmin1浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

you can use on show page event like this:

$("#page_id").on("pageshow" , function() {
  showMap();
});
发布评论

评论列表(0)

  1. 暂无评论