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....
on 2008-06-19 12:45
on 2008-06-19 13:30
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 2008-06-19 13:38
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 2008-06-19 15:04
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@gmail.com> 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.