O'Reilly logo

Ajax on Rails by Scott Raymond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controls

The script.aculo.us controls functionality (provided by controls.js and slider.js) provides JavaScript and Ajax-enhanced UI elements, namely auto-completing forms, in-place editors, and sliders.

Auto-Completion

Auto-completing fields come in two flavors: Autocompleter.Local (in which the auto-complete values are pre-loaded in JavaScript) and Ajax.Autocompleter (in which the auto-complete values are fetched dynamically via Ajax). Both classes extend Autocompleter.Base, an abstract class handling auto-completion independently of the data source for results.

CSS is used to control the appearance of auto-complete results. The suggested baseline rules look like this:

div.auto_complete       { width: 350px; background: #fff; }
div.auto_complete ul    { border:1px solid #888; margin:0;
                          padding:0; width:100%; list-style-type:none; }
div.auto_complete ul li               { margin:0; padding:3px; }
div.auto_complete ul li.selected      { background-color: #ffb; }
div.auto_complete ul strong.highlight { color: #800; margin:0; padding:0; }

Standard options

These options are available with both Autocompleter.Local and Ajax.Autocompleter.

ParamName
Name of the parameter for the string typed by the user on the autocompletion field. Defaults to the name of the element. 
Tokens
Enables multiple values to be entered into an auto-complete field. For example, setting tokens to a comma (,) will enable multiple values to be entered, separated by commas. The tokens option may also be an array of choices (e.g., [',', '\n']), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required