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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:42:55+00:00 2026-06-04T07:42:55+00:00

I’m building an app utilizing JQuery Mobile in which I’m showing a progress bar

  • 0

I’m building an app utilizing JQuery Mobile in which I’m showing a progress bar to indicate to the user their progress based on the steps completed.

For the progress bar I’m utilizing JQuery UI which is simple to implement

<script>
   $(document).ready(function(){     

        var currentStep = $("#formNumber").val(); //get the the current step from form  
    var totalSteps = 8;
    var formProgress = 0;

        // determine overall form progress after step is completed  
    if (currentStep >1) {         
        formProgress = (currentStep-1)/totalSteps*100;
        }   

    // Set progress value
    $("#progressbar").progressbar({value: formProgress});
    $('#percentage').text(formProgress);

   });// End function

</script>

However since the pages in JQuery Mobile are loaded via Ajax the progress bar does not show. I’m guessing it’s because the “#progressbar” div is empty.

if the pages loads without Ajax it will show the progress bar. Any one knows how i can solve this by allowing the progress bar to show when the page loads via Ajax

  • 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-04T07:42:56+00:00Added an answer on June 4, 2026 at 7:42 am

    Bind to pageinit not dom ready or in this case i bind to pageshow. In a JQM ajax app dom ready only happens once on the first page. So any new content brought into the dom doesn’t get the benefit of the code you wrote. Also when the second page is brought into the dom. The first page doesn’t go anywhere its just hidden. Because of this using the same id in every page causes problems. Get used to using classes instead. If you need to pick something out of the current page use the .ui-page-active class to help you select the appropriate element.

    Something like $('.ui-page-active .formNumber') will select the correct input for you. So here is my revised first step according to the info you gave me.

    index.html

    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <title>Step 1</title>
            <link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/start/jquery-ui.css" rel="stylesheet" />
            <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
            <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
            <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
            <script type="text/javascript">
                function getProgress(){
                    var currentStep = $(".ui-page-active .formNumber").val(); //get the the current step from form  
                    var totalSteps = 4;
                    var formProgress = 0;
    
                    // determine overall form progress after step is completed  
                    if (currentStep >1) {         
                        formProgress = (currentStep-1)/totalSteps*100;
                    }
                    $(".ui-page-active .progressbar").progressbar({value: formProgress});
                }
    
                $(document).on('pageshow',function(){
                    getProgress();
                });
            </script>
        </head>
        <body>
            <div data-role="page" id="step1">
    
                <div data-role="header">
                    <h1>Step 1</h1>
                </div><!-- /header -->
    
                <div data-role="content">
                    <input type="hidden" class="formNumber" value="1" />
                    <div class="progressbar"></div>
                    <a href="step2.html" data-role="button">Step 2</a>        
                </div><!-- /content -->
    
            </div>
    
    
        </body>
    </html>
    

    step2.html

    <div data-role="page" id="step2">
    
        <div data-role="header">
            <h1>Step 2</h1>
        </div><!-- /header -->
    
        <div data-role="content">
            <input type="hidden" class="formNumber" value="2" />
            <div class="progressbar"></div>
            <a href="step3.html" data-role="button">Step 3</a>        
        </div><!-- /content -->
    
    </div>
    

    step3.html

    <div data-role="page" id="step3">
    
        <div data-role="header">
            <h1>Step 3</h1>
        </div><!-- /header -->
    
        <div data-role="content">
            <input type="hidden" class="formNumber" value="3" />
            <div class="progressbar"></div>         
            <a href="step4.html" data-role="button">Step 4</a>        
        </div><!-- /content -->
    
    </div>
    

    …… and on and so forth

    If you interested I made a sample for you to look at. http://starwebservices.net/so/

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.