Hello, I''m using the Effect.toggle(''myElem'', ''slide'') effect to open and close a div. I''d like a callback function to be executed once the effect has finished. I tried adding the function like this: Effect.toggle(''myElem'', ''slide'', function() { //do something fun here }); But this did not work. How can I execute a function once the effect has finished? I tried just adding a normal function after the Effect.toggle line of code, but the function gets executed before the effect has finished... I''d like to avoid using setTimeout if possible.... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Furthermore, I discovered the afterFinish callback but it still does not work :( I have used the code: Effect.toggle(''myElem'', ''slide'', { afterFinish:alert("it has finished") }); But the alert is displayed before the effect has finished... Is this a bug? On Jun 19, 11:45 am, wellmoon <danwell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''m using the Effect.toggle(''myElem'', ''slide'') effect to open and > close a div. I''d like a callback function to be executed once the > effect has finished. I tried adding the function like this: > > Effect.toggle(''myElem'', ''slide'', function() { > //do something fun here > > }); > > But this did not work. How can I execute a function once the effect > has finished? I tried just adding a normal function after the > Effect.toggle line of code, but the function gets executed before the > effect has finished... > > I''d like to avoid using setTimeout if possible....--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry, my bad. I got it now. Inline functions do not work so well, defining the function as a variable elsewhere and calling it in the afterFinish property works fine... var myFunc = function() { //it works... } Effect.toggle(''myElem, ''slide'', { afterFinish: myFunc }); On Jun 19, 12:29 pm, wellmoon <danwell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Furthermore, I discovered the afterFinish callback but it still does > not work :( > > I have used the code: > > Effect.toggle(''myElem'', ''slide'', { afterFinish:alert("it has > finished") }); > > But the alert is displayed before the effect has finished... > > Is this a bug? > > On Jun 19, 11:45 am, wellmoon <danwell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello, > > > I''m using the Effect.toggle(''myElem'', ''slide'') effect to open and > > close a div. I''d like a callback function to be executed once the > > effect has finished. I tried adding the function like this: > > > Effect.toggle(''myElem'', ''slide'', function() { > > //do something fun here > > > }); > > > But this did not work. How can I execute a function once the effect > > has finished? I tried just adding a normal function after the > > Effect.toggle line of code, but the function gets executed before the > > effect has finished... > > > I''d like to avoid using setTimeout if possible....--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You can still define it inline: Effect.toggle(''myElem, ''slide'', { afterFinish: function() { //it works... } }); But good job sleuthing around and making it work. ;-) -Fred On Thu, Jun 19, 2008 at 6:37 AM, wellmoon <danwellman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Sorry, my bad. I got it now. Inline functions do not work so well, > defining the function as a variable elsewhere and calling it in the > afterFinish property works fine... > > var myFunc = function() { > //it works... > } > > Effect.toggle(''myElem, ''slide'', { afterFinish: myFunc });-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---