1

I have a function in pure JavaScript that flies out a div from the right. This could be written better, but I'm not worried about that right now.

If I manually call flyout(), it does what it's supposed to. If I call nextStep(), it does all the other stuff it's supposed to, except for calling flyout().

These functions are in the same file.

function flyout() {
    window.phases.style.left = window.innerWidth - (window.phases.style.width.replace("px","").valueOf());
    window.flown = true;
    phasesName = document.getElementById("phasesName");
    phasesBody = document.getElementById("phasesBody");

    phasesName.style.display = "none";
    phasesBody.style.display = "block";
}


function nextStep() {
    switch (window.stepName) {
        case "Step1":
            stepName = "Step2";
            step2();
            break;

        case "Step2":
            stepName = "Step3";
            step3();
            break;

        case "Step3":
            stepName = "Step4";
            step4();
            break;

        case "Step4":
            stepName = "Step5";
            step4();
            break;
    };
    flyout();
}

It does everything I want it to, except for calling flyout() function.

9
  • Why are your steps all messed up? Commented Jan 21, 2014 at 5:30
  • 1
    check in the browser JS console if there is any JS error; step2/3/4... methods may be failing thereby skipping the flyout() call Commented Jan 21, 2014 at 5:30
  • 1
    It looks like it works for me. jsfiddle.net/nT8Ha/1 Commented Jan 21, 2014 at 5:33
  • Where is this even defined...? window.stepName Commented Jan 21, 2014 at 5:34
  • if there is an error in any of your step functions, it will break the switch and never hit flyout. use the console!1 Commented Jan 21, 2014 at 5:35

2 Answers 2

1

The browser probably isn't getting down to the flyOut() call in nextStep(). Put console.log or alert about the flyOut() call in nextStep() and see if it is getting called.

Sign up to request clarification or add additional context in comments.

4 Comments

This is more of a comment.
I can't mark my own answer as "answered" for a couple days, and you helped me find the issue (the alert showed me the error). Have rep!
@David Well there you go. Now you can comment. :)
@Farfromunique I'm happy I could help you! :) Good luck with your project!
0

I'm an idiot. it is firing off, but it's being countered by a different function call immediately.

FWIW, the project is at https://github.com/farfromunique/vampirrePoints/ and yes, i know I typo'd vampire.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.