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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:39:41+00:00 2026-05-30T02:39:41+00:00

in this project im using jquery and phonegap i have a link that if

  • 0

in this project im using jquery and phonegap

i have a link that if clicked , changes the page:

$('#statsButtonmain').on('click', function() {
        $.mobile.changePage("stats.html", { transition: "slideup"}, true, true);  
});

this works fine, but i would like to run a function (playMusic()) when the transition is done, something like this:

$('#statsButtonmain').on('click', function() {
        $.mobile.changePage("stats.html", { transition: "slideup"}, true, true);  
            playMusic();
});

i found out that there is a pageshow event that gets triggered on the page being shown, after its transition completes, but im not sure how to use it

this doesn’t seem to work, any ideas?

Thanks

  • 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-05-30T02:39:43+00:00Added an answer on May 30, 2026 at 2:39 am

    I’ve not done a lot a jQuery mobile development so this might not be the most efficient solution. As you said, the pageshow event is what you need to use. Here are the 2 HTML files I ran locally in which I see the alert after the stats.html page transition is completed. The .live() is bound to the #stats element’s page pageshow event.

    HTML

    (saved as index.html)

    <!doctype html> 
    <html> 
      <head> 
        <title>Home</title> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('#statsButtonmain').on('click', function() {
               $.mobile.changePage('stats.html', { transition: 'slideup'}, true, true);  
            });
    
            $('#stats').live('pageshow', function(event, ui) {
              playMusic();
            });
    
            function playMusic() {
              alert('playing music');
            }
        });
        </script>
    </head> 
    <body>
    <div data-role="page" id="home">
        <div data-role="header">
           <h1>Callback test</h1>
        </div>
        <div data-role="content">
          <a href="#" id="statsButtonmain">click me</a>
        </div>
    </div>
    </body>
    </html>
    

    (saved as stats.html)

    <!doctype html> 
    <html> 
      <head> 
        <title>Stats</title> 
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.js"></script>
    </head> 
    <body>
    <div data-role="page" id="stats">
        <div data-role="content">some stats</div>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sample MVC project using jQuery grid. There is only one problem
I made a Blackberry Webworks project using jquery mobile and phonegap. When I go
I am doing a project using PhoneGap + jQuery Mobile in Android. I am
This is a Rails 3 project using jQuery 1.4.4. I have an index action
I am fluent in CSS and JS. Using jQuery on this project. I have
I've got a project using PhoneGap 1.0 and jQuery Mobile running on Android. I'd
This is a two-part question. I'm using jQuery for a project and wanting to
We have an ADP project created several years ago using Access 2000. This project
I have a Unit test project for my Application using DUnit framework. This project
I have this task for the project with 4 nested subprojects using Maven: For

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.