[jQuery] Re: Event callback question

2009-01-02 Thread Cam Spiers
Interesting I have figured out the reason why your example didn't work(and now does). It doesn't work when you have elements in the array which don't need animation/are in the same state initially as the final animation state. So I now have an active class indicating it's state and the selector I

[jQuery] Re: Event callback question

2009-01-02 Thread Ricardo Tomasi
Strange. In my tests the last element's callback was always called last. jQuery's animations are time-based, that means both animations should end at the same time, with a small offset for the last element at most. Anyway, you already have a solution. I had first rewritten yours before trying the

[jQuery] Re: Event callback question

2009-01-02 Thread Cam Spiers
Thats cool thanks Brian and Ricardo for your time. Ricardo that did look really good but it doesn't work for me. jQuery("div.mainLiner div.panel").not(':last') .slideUp(750, function(){ console.log("not last"); }).end() .filter(':last') .slideUp(750, function(){ console.log("last"); //callback }

[jQuery] Re: Event callback question

2009-01-01 Thread Ricardo Tomasi
You're right, that will run the callback once for each element. This is a bit hacky but is the shortest way I could think of: function closeMainPanels(){ jQuery("div.mainLiner div.panel").not(':last').slideUp(750).end() .filter(':last').slideUp(750, function(){ //callback

[jQuery] Re: Event callback question

2009-01-01 Thread Cam Spiers
They are all sliding up at the same time, but I was under the impression that your code would call the callback function once for each div.panel that was found. Am I mistaken? (would be really awesome if it does only call once) And if I'm not, I reiterate that I only want the callback function cal

[jQuery] Re: Event callback question

2009-01-01 Thread Ricardo Tomasi
If they are all sliding up at the same time, isn't it simpler to use function closeMainPanels(){ jQuery("div.mainLiner div.panel").slideUp(750, function(){ / *...callback...*/ }); } On Jan 1, 5:53 pm, "Cam Spiers" wrote: > function closeMainPanels(callback){ >     var panels = jQuery('div.m

[jQuery] Re: Event callback question

2009-01-01 Thread Cam Spiers
function closeMainPanels(callback){ var panels = jQuery('div.mainLiner div.panel'); var done = []; var length = panels.length; panels.each(function(){ var panel = jQuery(this); panel.slideUp(750, function(){ if (done.push(panel) == length){

[jQuery] Re: Event callback question

2008-12-31 Thread Cam Spiers
Thanks for your response. Yes I have used that before, but I need to know how to add a callback function which is called after a set of animations are completed. If I have an array of dom elements which all need the same animation applied to them, how can I tell when all the animations are comple

[jQuery] Re: Event callback question

2008-12-31 Thread brian
On Wed, Dec 31, 2008 at 11:26 PM, Cam Spiers wrote: > Hey, > > function closeMainPanels(){ > jQuery("div.mainLiner div.panel").each(function(){ > jQuery(this).slideUp(750); > }); > } > > How can I tell when all panels have finished animation? > > As I need to call another function