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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:58:14+00:00 2026-05-13T23:58:14+00:00

I have a process where a user puts in a comma delimited list that

  • 0

I have a process where a user puts in a comma delimited list that is then processed one item at a time. I want to be able to indicate to the user that it is processing and let them know when it is done. So I used the curtain idea from Borgar’s replay to … Div Over Page.
This worked but the curtain disappears well before the process is done. I believe it is because each call in the forEach loop inside the importIDs function is called asynchronously thus returning control back before it completes. (I know that is the idea behind asynchronous code.) So what do I need to do to keep the curtain up until it is done?

HTML that calls the function

<label>Import list:</label><input style="width: 30em;" type="text" id="jcDelimitedList"/><input onclick="importIDs('jcDelimitedList','selectedJobCodes','AddJobCode');" type="button" value="Do It"/>

import function

    importIDs = function(dList,nodeId,actionName){
    busyProcess(function(){
        var ids = dojo.byId(dList).value;
        dojo.forEach(ids.split(","),function(entry,i){doAssosiate(nodeId,actionName,null,dojo.byId(entry));});
    });

};

which calls the busy function

    busyProcess = function(callback){
    var ret;
    var curtain = document.body.appendChild(document.createElement('div'));
    curtain.id = "curtain";
    curtain.onkeypress = curtain.onclick = function(){return false;};
    try{
        ret = callback();
    }finally{
        curtain.parentNode.removeChild(curtain);
    }
    return ret;
};

which in turn processes the passed in loop that calls doAssosiate for each element in the array:

    doAssosiate = function(nodeID,actionName,evt,aNode){
    if(aNode==null)return;
    var node = dojo.byId(nodeID);
    var newNode;
    var target = evt!=null?evt.target:aNode;
    newNode = dojo.clone(target);
    var tID = target.id;
    var sUrl = "action/groups." + actionName + "?id=" + tID  + "&groupID=" + groupID + bustCache("&");
    var get = getDefered(sUrl);
    get.addCallback(function(data){
        node.appendChild(newNode);
        target.parentNode.removeChild(target);  
        return data;
    });
    get.addCallback(function(data){
        dojo.behavior.apply();
        return data;
    });
};

which runs each url with getDefered

getDefered = function(url){
console.log(url);
return dojo.xhrGet({
    url:url
});

};

I think I have all the relevant code above. I thought using sending the loop through the busy process would hold until finished and then return instead it holds until it fires off each iteration and then returns before they are complete.

As always thanks for any input and criticism.

  • 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-13T23:58:14+00:00Added an answer on May 13, 2026 at 11:58 pm

    A couple of interesting bugs in the above. Mainly if the list of ids in the array is to large it troughs more traffic at the database then it can handle. So I went to a recursive function instead of the foreach loop. Then removed the responsibility of turning off the curtain from busyProcess function and added it to the recursive call that turned the curtain off on exit of the recursion. For anyone that cares below are the changed functions. Also change to use dojox.widget.Standby for the curtain.

        busyProcess = function(callback){
        var ret;
        document.body.appendChild(standby.domNode);
        standby.show();
        ret = callback();
    
        return ret;
    };
    

    instead of calling doAssosiate now it calls assosiateAll;

        importIDs = function(dList,nodeId,actionName){
        busyProcess(function(){
            var ids = dojo.byId(dList).value;
            var sourceNode = dojo.byId(nodeId);
            assosiateAll(ids.split(","),0,sourceNode,actionName);
        });
    };
    
    
    
    
        assosiateAll = function(idArray,idx,sourceNode,actionName){
        if(idx <= idArray.length ){
            var target = dojo.byId(idArray[idx]);
            if(target == null){
                idx++;
                assosiateAll(idArray,idx,sourceNode,actionName);
            }else{
                var newNode = dojo.clone(target);
                var tID = target.id;
                var sUrl = "action/groups." + actionName + "?id=" + tID + "&groupID=" + groupID + bustCache("&");
    
                var get = getDefered(sUrl);
                get.addCallback(function(data){
                    sourceNode.appendChild(newNode);
                    target.parentNode.removeChild(target);
                    return data;                    
                });
                get.addCallback(function(data){
                    idx++;
                    assosiateAll(idArray,idx,sourceNode,actionName);
                    return data;
                });
                get.addCallback(function(data){
                    dojo.behavior.apply();
                    if (idx == (idArray.length -1)) {
                        standby.hide();
                    }
                    return data;
                });
            }
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iOS app I have several UIElement s that can process user input:
We have a nightly process that updates applications on a user's pc, and that
I have a service that spawns a WPF application process when a user logs
I have a process as follows: User does a complex search that is done
I have a process where an incoming user request to our system is being
I have two processes - a user process and a root-level LaunchDaemon. I'd like
So I have this process called svbc_gm.exe, and I start it as the user
Imagine I have an existing process running under windows as a particular user. Would
I have to use the EXEC family to find the process owned (the user)
I have a situation where user requests to do a long running process. I

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.