The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Need Function to Complete before Proceeding

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #39070

    Have a function called home. And well, obvious what is and what it does.

    function home() {


    proceed on to other code in the function….


    I have a fade to white effect that I call with function fadeTo(white). Problem is I need the code to wait until this function is complete before proceeding. How can I do this? I considered a callback function but that would mean after the outer function is done run the inner function, which does not work for me in this. I rather not use a timer.


    Why can’t you use a callback on the fadeTo?

    fadeTo(white, function() {
    // other stuff

    From the docs:
    .fadeTo( duration, opacity [, easing] [, callback] )


    I’m not sure what ‘white’ is in this case, either.


    Since I have a function called home() when the user presses the home() button, I would rather keep to that convention rather than replaced home with fadeTo. I wrote the fadeTo function myself, so I could rewrite the function if I had for it to be called first. For experimenting, I tried placing home() as a callback in fadeTo and called from home(), in which I got a error to much recursive.


    Well, for starters I would suggest not creating your own function that has the exact same name as one that jQuery uses itself.

    If you wrote fadeTo() yourself, I would just add in a callback for it. This will give you a good start:

    I’d also change the name of the function ;)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.