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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:46:39+00:00 2026-05-28T18:46:39+00:00

I found this great post on creating a progress bar with javascript: Show javascript

  • 0

I found this great post on creating a progress bar with javascript:
Show javascript execution progress

It works great for me except for one section of code I am unable to integrate.

Assuming this approach:

var process = {
steps: [
                function(){
                //processing
            },
            function(){
                //processing
            },
            function(){
                element.each(function(index){
                    //processing
                });
            },
            function(){
                //processing
            },
            function(){
                //processing
            }
],
index: 0,
nextStep: function(){
    this.steps[this.index++]();
    if (this.index != this.steps.length) {
        var me = this;
        window.setTimeout(function(){
            me.nextStep();
        }, 0);
    }
}

};

process.nextStep();

This works great. However, I have a process that works like this:

element.each(function(index){
     //do some processing
});

One way to integrate this would be just to throw it in a function like this:

function(){
     element.each(function(index){
          //do some processing
     });
},

However, about 70% of the processing is done in this loop. So it kind of defeats the purpose of the progress bar if it for example jumps from 10% to 80%. What I would like to do is treat each iteration of this each loop as an anonymous function in the steps section. So the end goal is that in addition to counting each already defined function as a step each iteration of my each loop will be counted as a step Any ideas on how to do this? I tried to just throw the .each loop in there, but have had no success.

Thanks for the help.

  • 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-28T18:46:40+00:00Added an answer on May 28, 2026 at 6:46 pm

    This is a bit of a hack, but you can use the each() loop to populate a queue with your processing steps and subsequently execute that queue. In this case, I use an empty jQuery object as the queue. The setTimeout is required to make visibly changes the DOM.

    For example:

    var myQueue = $({});    
    
    element.each(function(index){
        myQueue.queue('stack', function() {
            //do some processing
            setTimeout(function() { myQueue.dequeue('stack'); }, 10);
       }
    });
    

    The above works for jQuery 1.3, if using v1.4+:

    var myQueue = $({});    
    
    element.each(function(index){
        myQueue.queue('stack', function(next) {
            //do some processing
            setTimeout(function() { next(); }, 10);
       }
    });
    

    Once the queue is built and populated from your each loop, you can start the queue with:

    myQueue.dequeue('stack');
    

    See also What are queues in jQuery?

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

Sidebar

Related Questions

I found this question which is a great starting point towards creating embedded widgets
I found this great post by @hugoware about parsing values: http://hugoware.net/blog/more-control-when-parsing-values . I re-used
I found this great Tablesorter plugin for jQuery but I can't make it work
I have just found this great tutorial as it is something that I need.
In .Net, I found this great library, HtmlAgilityPack that allows you to easily parse
Reading this question I found this as (note the quotation marks) code to solve
So I saw this great blog post, Experimenting with Node.js . I decided to
I'm trying to generate DTO's with T4. I found a great blog post that
I am following this great post to configure my rails production server on ubuntu
This is a follow up post to this one: Recursively search nested lists I've

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.