views:

135

answers:

1

Hello, I can't call callback after animation ends. Here is my animation function:

function animate( parentElement, callback )
{
        parentElement.animate({
            "height" : "hide", "opacity" : 0.0
        }, { duration : "slow"}, "linear", callback);
}

And here is calling it:

 animate( $(this).parent(), function() { alert('test'); } );

Alert doesn't show, why?

+3  A: 

Here's your problem:

    parentElement.animate({
        "height" : "hide", "opacity" : 0.0
    }, { duration : "slow"}, "linear", callback);

That second parameter? It's supposed to be either a string or a number. When you pass in an object, jQuery doesn't know what to do with it. Switch to this:

    parentElement.animate({
        "height" : "hide", "opacity" : 0.0
    }, "slow", "linear", callback);

...and it'll work just fine.

Shog9
Dead on. I just figured it out and came to post...darn you for being smarter and faster =P
Topher Fangio
Hm... It was really my problem. Thanks.
Ockonal