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 8382577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:57:36+00:00 2026-06-09T16:57:36+00:00

I would like to extend $.mobile.changePage to accept more options such as adding a

  • 0

I would like to extend $.mobile.changePage to accept more options such as adding a callback function for when the page finishes loading as well as more options for the AJAX call like contentType. Is there a way to do this without changing the source code? If not, I am willing to change the source code for educational purposes, but could not find it in the jQuery Mobile GitHub: https://github.com/jquery/jquery-mobile . Thanks for any helps or guidance.

  • 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-09T16:57:37+00:00Added an answer on June 9, 2026 at 4:57 pm

    One of the more exciting parts of JavaScript is that ability to redefine any function using a technique which is commonly referred to as Monkey Patching. (as an aside ES5 provides a new freeze method which allows developers to prevent such modifications.)

    Here’s an example of a JavaScript MonkeyPatch which allows us to modify the behaviour of a function without editing it’s source:

    // A namespace object.
    var Example = {};
    
    // Sums two values.
    Example.sum = function (a, b) {
        return a + b;
    }
    
    // Usage:
    var result = Example.sum(1, 2);
    

    Say we wanted to add logging to the sum method, we could just add a console.log line to the function, but we can also monkey patch it:

    // Store a reference to the current 'Example.sum' function.
    var originalSum = Example.sum;
    
    // Now redeclare Example.sum...
    Example.sum = function (a, b) { 
    
        // Call the originalSum function first...
        var result = originalSum(a, b);
    
        // Now add some logging...
        console.log("Example.sum(" + a + ", " + b + ") yields " + result);
    
        return result;
    };
    

    Now when Example.sum is called, not only will we get the result as before, but a console message will also be written. With this in mind, you can monkey patch the $.mobile.changePage method in the same way:

    var originalChangePage = $.mobile.changePage;
    
    // Redefine `changePage` so it accepts a 'complete' function in the options
    // object which will be invoked when the page change is complete.
    $.mobile.changePage = function (to, options) {
        if (typeof options.complete === "function") {
            $(body).one("pagechange", function (event) { 
                options.complete(event);
            });
        }
    
        originalChangePage(to, options);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASPX page (with VB Codebehind). I would like to extend the
I would like to extend my onclick parameter of button_to_remote with another javascript function
I would like to extend the team explorer work item editor with a custom
I would like to extend a kd-tree (2D) class to be able to remove
I would like to extend a liferay core jsp by custom-jsp hook. In this
For a project of mine I would like to extend twitter bootstrap modal window
I would like to create extend a Java Swing application to have a look
I would like to make abstract class which has several inner classes extend it
To extend RavenDB's capabilities I would like to install the bundles that are available
I'm trying to extend my ActiveRecord class with some dynamic methods. I would like

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.