Bruno
Bruno

Reputation: 1042

change page with function

Im new to Javascript and HTML. I can't find what I am doing wrong, my objective is:

From a dummy login page, I click on the login button and It takes me to a page where It loads comic books from themoviedb API.

The problem Is that It won't change to the comic books page:

Here is the working code: JSFiddle link

Code in question:

function goToListView() {
$(':mobile-pagecontainer').pagecontainer('change', '#listMenuPage', {
    transition: 'pop',
    changeHash: false,
    reverse: true,
    showLoadMsg: true
});

}

Upvotes: 0

Views: 69

Answers (2)

ezanker
ezanker

Reputation: 24738

Instead of inline code on your button, move it into the pagecreate of the login page:

$(document).on("pagecreate", "#loginPage", function(){
    $("#btnLogin").on("click", function(){
        goToListView();
        return false;
    });
});

Here is your updated (and simplified) FIDDLE

Note: in the fiddle I set the code to "No Wrap - in <body>"

Upvotes: 1

Youness
Youness

Reputation: 1495

function goToListView() {
    $.mobile.changePage('#listMenuPage');
   }

PS : dont try it in jsfiddle try it in your html file becouse somehow jsfiddle donest recognise the function

Upvotes: 0

Related Questions