Akhilesh Sharma
Akhilesh Sharma

Reputation: 1628

Change Page does not work in jquery mobile ios and phonegap

I am explaining the situation below which currently I am facing for the app I am working on.

The app consists of the Login module which stores the data to the application local storage. Now when I initiate the application it checks for the key in the local storage and accordingly call the changepage in the application.

If i clear out the local storage and restarts the application then all the transitions works perfect. But if data is already there in the application local storage and application is launched it takes me to the home screen defined.

I have a jquery listview over there. Now when i call changePage in later scenario nothing happens i.e when i land up to the home page. But in the first scenario everything works fine when i start from the login screen.

Here is the code to logout

localStorage.removeItem("userdata");
            localStorage.removeItem("default_data");
            $("#block-ui").show();
            $.mobile.loading('show');
            setTimeout(function(){
                $.mobile.loading('hide');
                $("#block-ui").hide();
                $.mobile.changePage("index.html",{allowSamePageTransition:true,reloadPage:true,changeHash:false,transition:"slide"});
                },2500);

Upvotes: 1

Views: 5162

Answers (1)

Akhilesh Sharma
Akhilesh Sharma

Reputation: 1628

Finally I am able to solve the problem.

As per the understanding the jquery mobile loads the index.html as initial page and load the other html pages using ajax into the application. So the base level never changes from index.html to any other page.

Now the problem was due to the following syntax

$.mobile.changePage("home.html",{allowSamePageTransition:true,reloadPage:true,changeHash:true,transition:"slide"});

I just changed it to following:

$.mobile.changePage("home.html",{allowSamePageTransition:true,reloadPage:false,changeHash:true,transition:"slide"});

and it started to work.

Thanks anyways for the help. Moreover you can check out the following link to better understand the pitfalls and accordingly handling them:

http://rip747.wordpress.com/2012/04/19/pitfalls-with-jquery-mobile-and-how-to-over-come-them/

Upvotes: 3

Related Questions