FuriousD
FuriousD

Reputation: 854

JQuery Animate callback function not working

I cannot get the following callback function to work. The alert is never triggered. The initial animation is performed on '.carousel-images' however.

$('.carousel-images').animate({'left' : left_indent},{queue:false, duration:500},function(){
    alert("animate carousel");

    //get the first list item and put it after the last list item   
    $('.carousel-images li:last').after($('.carousel-images li:first'));  

    //get the left indent to the default  
    $('.carousel-images').css({'left' : '-1200px'});  
});

Any assistance would be greatly appreciated!

Upvotes: 4

Views: 827

Answers (2)

Raver0124
Raver0124

Reputation: 522

your syntex is wrong, it should be

$('.carousel-images').animate({'left' : left_indent},{queue:false, duration:500, complete: function () {
                ...
            }
        });

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388316

Since you are using the second method the complete callback has to be passes as a property to the options object

You need to use

$('.carousel-images').animate({'left' : left_indent},{queue:false, duration:500, complete: function(){
    alert("animate carousel");

    //get the first list item and put it after the last list item   
    $('.carousel-images li:last').after($('.carousel-images li:first'));  

    //get the left indent to the default  
    $('.carousel-images').css({'left' : '-1200px'});  
}});

Upvotes: 1

Related Questions