Module | ActionView::Helpers::ScriptaculousHelper
In: | lib/action_view/helpers/scriptaculous_helper.rb

Provides a set of helpers for calling Scriptaculous JavaScript functions, including those which create Ajax controls and visual effects.

To be able to use these helpers, you must include the Prototype JavaScript framework and the Scriptaculous JavaScript library in your pages. See the documentation for ActionView::Helpers::JavaScriptHelper for more information on including the necessary JavaScript.

The Scriptaculous helpers’ behavior can be tweaked with various options. See the documentation at script.aculo.us for more information on using these helpers in your application.

### Methods

draggable_element drop_receiving_element sortable_element visual_effect

### Constants

TOGGLE_EFFECTS | = | [:toggle_appear, :toggle_slide, :toggle_blind]

### Public Instance methods

draggable_element(element_id, options = {})

Makes the element with the DOM ID specified by `element_id` draggable.

Example:

      <%= draggable_element("my_image", :revert => true)

You can change the behaviour with various options, see script.aculo.us for more documentation.

drop_receiving_element(element_id, options = {})

Makes the element with the DOM ID specified by `element_id` receive dropped draggable elements (created by draggable_element). and make an AJAX call By default, the action called gets the DOM ID of the element as parameter.

Example:

      <%= drop_receiving_element("my_cart", :url =>
        { :controller => "cart", :action => "add" }) %>

You can change the behaviour with various options, see script.aculo.us for more documentation.

sortable_element(element_id, options = {})

Makes the element with the DOM ID specified by `element_id` sortable by drag-and-drop and make an Ajax call whenever the sort order has changed. By default, the action called gets the serialized sortable element as parameters.

Example:

      <%= sortable_element("my_list", :url => { :action => "order" }) %>

In the example, the action gets a "my_list" array parameter containing the values of the ids of elements the sortable consists of, in the current order.

You can change the behaviour with various options, see script.aculo.us for more documentation.

visual_effect(name, element_id = false, js_options = {})

Returns a JavaScript snippet to be used on the Ajax callbacks for starting visual effects.

Example:

      <%= link_to_remote "Reload", :update => "posts",
            :url => { :action => "reload" },
            :complete => visual_effect(:highlight, "posts", :duration => 0.5)

If no element_id is given, it assumes "element" which should be a local variable in the generated JavaScript execution context. This can be used for example with drop_receiving_element:

      <%= drop_receving_element (...), :loading => visual_effect(:fade) %>

This would fade the element that was dropped on the drop receiving element.

For toggling visual effects, you can use :toggle_appear, :toggle_slide, and :toggle_blind which will alternate between appear/fade, slidedown/slideup, and blinddown/blindup respectively.

You can change the behaviour with various options, see script.aculo.us for more documentation.

[Validate]