WrapMode.Once not working?

The following is my code that sets up the animations that are played when certain events occur. For some reason however I can only get the WrapMode.Once to work on the jump animation, the attack one just loops. Someone please help?

Code:

private void Setup()
{
    _moveDirection = Vector3.zero;
    animation.Stop();
    animation.wrapMode = WrapMode.Loop;
    animation["jump"].layer = 1;
    animation["jump"].wrapMode = WrapMode.Once;
    animation["attack"].wrapMode = WrapMode.Once;
    animation.Play("idle");
    _run = true;
    _jump = false;
    _attackButton = false;
}

When the wrapmode of the animation is set to once, it will play once. If it loops instead you either set the wrapmode somewhere else to loop, or you run the animation over and over again. You didn’t include where and how you run your attach animation, so i guess there’s the problem.