Autocompleter.Local

The local array autocompleter.

 

Used when you’d prefer to inject an array of autocompletion options into the page, rather than sending out Ajax queries.

 

Syntax

 

new Autocompleter.Local(inputElement, choicesElement, dataArray, [options])

 

The constructor takes four parameters. The first two are, as usual, the id of the monitored textbox, and id of the autocompletion menu. The third is an array of strings that you want to autocomplete from, and the fourth is the options block.

 

Extra local autocompletion options:

 

·choices: How many autocompletion choices to offer
·partialSearch: If false, the autocompleter will match entered text only at the beginning of strings in the autocomplete array. Defaults to true, which will match text at the beginning of any word in the strings in the autocomplete array. If you want to search anywhere in the string, additionally set the option fullSearch to true (default: off).
·fullSearch: Search anywhere in autocomplete array strings.
·partialChars: How many characters to enter before triggering a partial match (unlike minChars, which defines how many characters are required to do any match at all). Defaults to 2.
·ignoreCase: Whether to ignore case when autocompleting.Defaults to true.

 

It’s possible to pass in a custom function as the ‘selector’ option, if you prefer to write your own autocompletion logic. In that case, the other options above will not apply unless you support them.

 

Example

 

<p><label for="bands_from_the_70s">Your favorite rock  band from the 70's:</label><br />

<input id="bands_from_the_70s" autocomplete="off" size="40" type="text" value="" /></p>

 

<div class="page_name_auto_complete" id="band_list" style="display:none"></div>

 

<script type="text/javascript">

new Autocompleter.Local('bands_from_the_70s', 'band_list', ['ABBA', 'AC/DC', 'Aerosmith', 'America', 

                       'Bay City Rollers', 'Black Sabbath', 'Boston', 'David Bowie', 'Can', 

                       'The Carpenters', 'Chicago', 'The Commodores', 'Crass', 'Deep Purple', 

                       'The Doobie Brothers', 'Eagles', 'Fleetwood Mac', 'Haciendo Punto en Otro Son', 

                       'Heart', 'Iggy Pop and the Stooges', 'Journey', 'Judas Priest', 

                       'KC and the Sunshine Band', 'Kiss', 'Kraftwerk', 'Led Zeppelin', 'Lindisfarne (band)', 

                       'Lipps, Inc', 'Lynyrd Skynyrd', 'Pink Floyd', 'Queen', 'Ramones', 'REO Speedwagon',

                       'Rhythm Heritage', 'Rush', 'Sex Pistols', 'Slade', 'Steely Dan', 'Stillwater', 

                       'Styx', 'Supertramp', 'Sweet', 'Three Dog Night', 'The Village People', 

                       'Wings (fronted by former Beatle Paul McCartney)', 'Yes'], {});

</script>