tags:

views:

5766

answers:

2

I am using slideDown animation to show some divs in a newly added table row:

$("div", newRow).slideDown(10000, UpdateHours(response.d.Hours));

however the UpdateHours() function is called long before the divs are finished animating. This is causing me a problem because the Updated Hours then get covered by the sliding divs.

I made the slide very slow to illustrate the issue better.

+14  A: 

I think it's trying to pass the result of the call UpdateHours(response.d.Hours) as the callback function, which would explain why it is being called so soon. One solution would be to create an anonymous function that calls UpdateHours.

$("div", newRow).slideDown(10000, function () { UpdateHours(response.d.Hours) });

There is a demo for calling slideDown this way on the jQuery site. http://docs.jquery.com/Effects/slideDown

Tracy Hurley
Great that was it, thanks for that!
Sam Mackrill
+2  A: 

I think you want this:

$("div", newRow).slideDown(10000, function() { UpdateHours(response.d.Hours); });

This creates an anonymous function that will be called as a callback - what you're doing is setting the callback to be the return value of UpdateHours

Greg