javascriptjqueryjquery-mobilecordovajquery-mobile-button

How to stop page to reload again after redirection


I'm developing an app using Phonegap, the problem is when I go to a page it changes the URL but doesn't load the page. It refreshes the page and put the user back on the same page where he was.

Default URL: localhost/pg_proj/www/index.html#gameDashboardPage

User Clicks on a link to go to the below URL

localhost/pg_proj/www/index.html#pendingChallengesPage

In the address bar, it changes the URL from #gameDashboardPage to #pendingChallengesPage but it doesn't load the #pendingChallengesPage page, instead it just refreshes the page and put the user back on #gameDashboardPage

Any suggestions will be great thanks


Solution

  • If I understood it correctly, it's not just refreshing the page. Your code on #pendingChallengesPage might contain code that redirects again back to it's previous. Please mention it, Is the URL is persist after reload? You've clearly stated that page content is not changing. What about the URL?

    1) If you are redirecting inside a function twice, return; the function after it's first redirection.

    2) Use event.preventDefault(); if necessary.

    Reply with some more details. if you could, throw few script here.