views:

59

answers:

3

  I would like to use fx and functions I have a animation, and i would like to, at the end of the queue, do an ajax call.
  I can't seem to make it work...
  I have absolutely no idea how to procede...

that would a very very rough example, but

$('#dvHeader').queue(function() {
  $('#dvLeftContent').slideDown(2000);
  $('#dvRightContent').animate({ backgroundColor: '#c71717' }, 2500)
  callAjax();
}

  This code calls the callAjax function way before the last effect starts, in fact, almost as the first one is called.
  The real case is a little more complex, i cannot use a callback of the animate effect, per example. I would like to know when the queue ends the last effect, or something like it.
  How could I make that call to be triggered at the end of the last animation?

+1  A: 

see http://docs.jquery.com/Effects/animate

Try to set the callback method of the last effect (animate(), in your case) to your ajax function:

animate( params, [duration], [easing], [callback] )

rekindleMyLoveOf
As I've said before, I wanted to know how to apply a function at the end of the animation of the last element. The regular callback and chain are not what i am looking for. Thanks anyway
NoProblemBabe
A: 

Chain your animations along with your call together using the callback mechanisms:

$('#dvHeader').queue(function() { 
  $('#dvLeftContent').slideDown(2000, function() {
      $('#dvRightContent').animate({ backgroundColor: '#c71717' }, 2500, function() { 
          callAjax();
      });
  });
});
tvanfosson
As I've said before, I wanted to know how to apply a function at the end of the animation of the last element. The regular callback and chain are not what i am looking for. Thanks anyway
NoProblemBabe
A: 

After a little more careful look on how those Queues work, i found that if I just know the last element that will have it animated, i can queue my ajax call to it, it will place my function after the animation, something like:

$('#dvHeader').queue(function() {
  $('#dvLeftContent').slideDown(2000);
  $('#dvRightContent').animate({ backgroundColor: '#c71717' }, 2500);     
}

$('#dvRightContent').queue(function() {
  callAjax();
});

Of course, having the very same behavior that the callback.
Thank you all for helping.

NoProblemBabe