David
David

Reputation: 10738

jquery fadeout timing

I'd like this function to fade the contents of the div out, wait till the fadeout is finished, then fade the new calendar in. What's happening is the new calendar gets loaded, then the fade out and fadein occur. Its like it loads the calendar and then blinks. I can't tell if the load is happening durring the fade out but the timing is definitely off. The fadeout() function isn't waiting till the fade completes to fire the loadContent function. Anybody know how i can fix this?

function ajaxCalendar(X,Y,Z){
            $('#ajaxdiv').fadeOut('300',loadContent());  

            function loadContent() {  
                var changemonthlink = "http://localhost:8888/myproject/calendar/view/" + X + "/" + Y + "/" + Z + "/1";
                $('#ajaxdiv').load(changemonthlink,'',function(){
                   $('#ajaxdiv').fadeIn('300'); 
                });
            }
            return false;   

};

Upvotes: 2

Views: 214

Answers (1)

Dogbert
Dogbert

Reputation: 222198

$('#ajaxdiv').fadeOut('300', loadContent());  

should be

$('#ajaxdiv').fadeOut('300', loadContent);

as you need to pass the function not the result of a function call.

Upvotes: 3

Related Questions