Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript - Scriptaculous - Effect Callback function

I am using scriptaculous to perform a slidedown effect using the following code:

Effect.SlideDown('dom_element_id');

I then hide the button which initiates this effect using:

$('button_id').hide();

The issue is that the button is hidden before the animation effect is complete, I would like it to hide after the animation effect is complete. I could not find a callback parameter for Effect.SlideDown.

like image 422
Hamish Avatar asked Apr 24 '26 11:04

Hamish


1 Answers

You can pass the afterFinish option to pass a callback to be run after the effect has been completed.

Effect.SlideDown('dom_element_id', { afterFinish: function () {$('button_id').hide(); } } );

EDIT

Note that beforeFinish, afterFinish, beforeSetup, afterSetup, beforeUpdate and afterUpdate options can be used for any effects as they are part of Effect.Base.

Also see the official docs here.

like image 162
Jonathan Fingland Avatar answered Apr 26 '26 01:04

Jonathan Fingland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!