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

  • Home
  • SEARCH
  • 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 7867121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:37:25+00:00 2026-06-03T00:37:25+00:00

I have a function called: this.makeStuffHappen() Which makes different animations according to a switch

  • 0

I have a function called:

this.makeStuffHappen() 

Which makes different animations according to a switch statement and a couple of variables. Is it possible to make a function not fire unless all previous are done resolving.

I want to write something like

$('button').click(function(){
    a.makeStuffHappen();
    b.makeStuffHappen();
    c.makeStuffHappen();
    d.makeStuffHappen();
});

And then it should only run b after a is done, c after b is done and d after c is done. Is it only possible to make animations wait for the previous by chaining them? Is it possible to chain any function?

Edit: makeStuffHappen() is animating different elements so a.makeStuffHappen() will animate a different element than b.makeStuffHappen and so on.

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-06-03T00:37:27+00:00Added an answer on June 3, 2026 at 12:37 am

    A callback would be the easiest way, but since you don’t want to use a callback (which jQuery’s .queue() does require – well… a recursive callback anyways), you could let the methods you have return a bool:

    $('button').click(function()
    {
        var theObjects = [a,b,c,d];
        for (var i=0;i<theObjects.length;i++)
        {
            if (theObjects[i].makeStuffHappen() === false)
            {
                break;//or throw, or whatever...
            }
        }
    });
    

    Of course, it is well possible the methods may vary depending on which object is called. You could work around this by using an object instead of an array, in which case your event handler could look something like:

    $('button').click(function()
    {
        var theObjects = {a:'aMethod',b:'bMethod',c:'cMethod'};
        for(var i in theObjects)
        {
            if (theObjects.hasOwnProperty(i))
            {
                if(window[i][theObjects[i]]() === false)
                {
                    break;//or throw, or return...
                }
            }
        }
    });
    

    Mind you, I don’t know why you don’t want to use some form of callback here, as it would be the easiest way to go… but that is, of course, none of my concern… 🙂

    Well, had a quick look at your game… seems fun, keep working on it :). BTW, you’re one step away from using callbacks all over the place:

    $('#placeBet').click(function() {
        placeBet();
    });
    

    Can be written as:

    $('#placeBet').click(placeBet);
    

    In the latter, placeBet is a callback function.
    I think you’re main concern is here:

    player.printHand();
    dealer.printHand(isDealerHidden);
    

    What I’d do here, is change the printHand function, by adding this at the end:

    if (this.name !== 'dealer')
    {
        dealer.printHand(isDealerHidden);
    }
    

    I haven’t read enough of your script to make this work as you need it to, but you get the idea… An easier way would be not to animate the dealer explicitly, but alter all animators of the players hand to end with some code that animates the dealer after the players animation is completed… I know, I’m talking gibberish, but I’m at work… and sick… Good luck, anyway. I might take some more time checking your progress, maybe read your script more closely tonight and edit this dribble to something that will actually work 🙂

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

Sidebar

Related Questions

Say I have this repeater which makes use of a public function called Test
Now I'm sure this is super easy, I have a function called remove_deposit which
I have a function which calculates distance from database records. This function is called
I have this code which is called at an onChange event of an function
So I have this code which is called in a print_info() function after a
I have a function called block which simply return false; this is meant to
In zsh, I have a function called g which acts like this: with no
Say, I have some scope with variables, and a function called in this scope
I have this function called ProperCase that takes a string, then converts the first
Suppose I have a free function called InitFoo . I'd like to protect this

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.