Flowdock
method

auto_complete_field

Importance_3
v1.0.0 - Show latest stable - 2 notes - Class: ActionView::Helpers::JavaScriptMacrosHelper
auto_complete_field(field_id, options = {}) public

Adds AJAX autocomplete functionality to the text input field with the DOM ID specified by field_id.

This function expects that the called action returns a HTML <ul> list, or nothing if no entries should be displayed for autocompletion.

You’ll probably want to turn the browser’s built-in autocompletion off, su be sure to include a autocomplete="off" attribute with your text input field.

Required options are:

:url:URL to call for autocompletion results in url_for format.

Addtional options are:

:update:Specifies the DOM ID of the element whose innerHTML should be updated with the autocomplete entries returned by the AJAX request. Defaults to field_id + ‘_auto_complete’
:with:A JavaScript expression specifying the parameters for the XMLHttpRequest. This defaults to ‘fieldname=value’.
:indicator:Specifies the DOM ID of an element which will be displayed while autocomplete is running.
:tokens:A string or an array of strings containing separator tokens for tokenized incremental autocompletion. Example: :tokens => ',' would allow multiple autocompletion entries, separated by commas.
:min_chars:The minimum number of characters that should be in the input field before an Ajax call is made to the server.
:on_hide:A Javascript expression that is called when the autocompletion div is hidden. The expression should take two variables: element and update. Element is a DOM element for the field, update is a DOM element for the div from which the innerHTML is replaced.
:on_show:Like on_hide, only now the expression is called then the div is shown.
Show source
Register or log in to add new notes.
August 4, 2008
1 thank
November 21, 2008 - (>= v2.0.0)
0 thanks

Installation

Install the plugin by typing

script/plugin install auto_complete

Remember to restart webservice :)