Consider the following code:

        $form['actions']['submit']['#ajax'] = array(
            'wrapper' => 'apple-node-form',
            'callback' => 'node_add_callback',
            'method' => 'replace',
            'effect' => 'fade'

This will produce a JavaScript fade animation. But how can I define my own animations? For example, 'effect' => 'myCustomAnimation'.

I'm really just looking for a way to be able to define my own JavaScript function, and have that function handle the AJAX request. I could just call .ajaxComplete() on the document and have a series of switch statements in there that figure out what to do with the response. But that's a bit hacky, and the switch statements (as well as the initial response parsing) would be additional logic. If I can just define right there in the $form array PHP code the JS function to be used, no ugly switch statement would be necessary.

1 Answer 1


It appears you need to install the interface elements library to add custom effects.

As indicated in the forms api.



Description: Specifies the effect used when adding the content from an AJAX request.

Values: String. Possible values: 'none' (default), 'fade', 'slide'. If the interface elements library is installed, any effect with the name effectToggle may also be used.

I hope this helps :)

  • I've updated it. Let me know if that helps.
    – maxedison
    Commented May 2, 2012 at 10:47
  • Did you have any luck?
    – dibs
    Commented May 7, 2012 at 0:00
  • Sorry for being MIA -- haven't had a chance to try it yet, but this does look like the right answer.
    – maxedison
    Commented May 19, 2012 at 13:46
  • Did it work for you?
    – dibs
    Commented Jun 13, 2012 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.