Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:46:26+00:00 2026-06-18T08:46:26+00:00

I have a problem where the pagechange handler is firing twice within my app

  • 0

I have a problem where the pagechange handler is firing twice within my app for some page transitions.
In deviceready handler:

$(document).bind("pagechange", onPageChange);

Then the hander:

var onPageChange = function (event, data) {
    var fromPageId = null;

    //Get the ID of the page we are transitioning to.
    var toPageId = data.toPage.attr("id");

    //Get the ID of the page we are coming from.
    if (data.options.fromPage) {
        fromPageId = data.options.fromPage.attr("id");
    }

    console.log("pagechange to " + toPageId + " from " + fromPageId);

    switch (toPageId){
        ...
    }
}

When the app transitions from one page to the next, I can see in LogCat that the onPageChange is firing twice:

01-26 18:49:50.490: I/Web Console(18244): pagechange to care-plan-view from care-plan-view:25
01-26 18:49:50.490: I/Web Console(18244): pagechange to care-plan-view from care-plans:25

This is the order they appear in the log, weird thing is that the care-plan-view is the destination page and the care-plans is the start page!

This is a sample link that will cause the page transition issue:

<a data-role="button" data-icon="arrow-r" data-iconpos="right" href="#care-plan-view?id=9e273f31-2672-47fd-9baa-6c35f093a800&amp;name=Sat"><h3>Sat</h3></a>

Any ideas why this would be happening?

Cheers,
Don

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:46:27+00:00Added an answer on June 18, 2026 at 8:46 am

    The reason the pagechange event occurs twice is due to the recursive call in changePage when toPage is not a jQuery enhanced DOM object.

    This recursion is dangerous, as the developer is allowed to change the toPage within the event. If the developer consistently sets toPage to a string, within the pagechange event handler, regardless of whether or not it was an object an infinite recursive loop will result.

    The pageload event passes the new page as the page property of the data object (This should be added to the documentation, it’s not listed currently). The pageload event could therefore be used to access the loaded page.

    In few words this is happening because you are sending additional parameters through pageChange.

    To fix this problem choose an another page event, like:

    event pagebeforecreate
    event pagecreate
    event pageinit
    event pagebeforehide
    event pagebeforeshow
    event pageremove
    event pagehide
    event pageshow
    

    More about this problem can be found in my blog ARTICLE, just search for the chapter: Prevent multiple event triggering. Or you can find it HERE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with jquery mobile. always my page is called this
I have problem with customizing each page using pagecontrol and UIScrollView. I'm customizing Page
I have problem calling a JavaScript function in an iframe from the parent page.
I have problem with deserialize document to object using XmlSerializer class. Code my function
I have problem with infinite loop in Grails app when rejectIfNoRule = true I
Have problem with linq expressions. I want to get from db some data ordered
I have problem with chrome.extension and jQuery Post. I want post some data (get
I have a very strange problem in an ASP.NET page, the following reference of
I have problem with some JS virus on all of my websites. They're on
we have problem with slow insert statement using 40 bind variables as columns values.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.