Auto Complete 4.1 Options

'ajax.php'
ajax - String

URL of the server side script.

Note*: When dataSupply has a length greater than 0, no ajax request is sent.

50
cacheLimit - Integer

Limit's the number of entries stored in cache.

undefined
dataFn - Function(inputval, value, currentList, i, dataSupply)

Personal function to use in place of default pattern matching. Return true for correct match, false for incorrect. Function Params:

-inputval: Current value within the textbox that is in focus.
-value: Value of the entry in the dataSupply array.
-currentList: Holds the current values that have passed this functions pattern match.
-i: Current index of the dataSupply array.
-dataSupply: The complete array passed to the autoComplete function


Note*: The this object references the input currently in focus.

[]
dataSupply - Array

Array of values/objects to run auto-complete as local instead of ajax requests. Default pattern match is: "/^(input value)/i"

100
delay - Integer

Time delay of when to send the ajax requests in milliseconds.

returns current input
inputControl - Function(inputval, keyCode)

inputControl gives you access to changing the name for cache storage. When doing pattern matching, or sending requests, the string returned by this function is used.

'auto-complete-list'
list - String

CSS Class that will be attached to the UL created.

-1
maxItems - Number

Limits the number of values added to the drop down list. When -1, no limit is imposed.

0
maxRequests - Integer

Maximum number of ajax requests allowed within a scripts duration. If 0, no limit is applied

1
minChars - Integer

Minimum number of required characters to send server side.

{}
postData - Object

Parameters that get passed to the server. The value defined by postVar will be overridden by the users input.

'value'
postVar - String

Name of the users input as it gets posted to the server.

false
preventEnterSubmit - Boolean

Prevents form submission when user selects a value from the UL drop down list using the enter key.

'post'
requestType - String / jQuery Fn

Type of request during ajax calls. Only use 'get' or 'post'.

'auto-complete-list-rollover'
rollover - String

CSS Class toggled on li elements when mouseover or up/down events occur.

true
useCache - Boolean

Tells autoComplete whether or not to use script level caching.

Input Width
width - Float

Width of the UL drop down list. Default's to the width of the Input field

Events

Note*: The this object references the input field currently in focus.

Empty Function
onBlur - Function(val, $ul)

Callback function when the user loses focus on the input field. Has a 150 millisecond delay.

Empty Function
onFocus - Function($ul)

Callback function when the user focuses on the input field.

Empty Function
onMaxRequest - Function(val, $ul)

Callback function when maximum number of ajax requests is reached. Will only fire if maxRequests is not 0.

Empty Function
onSelect - Function(data, $li, $ul)

Callback function when the user selects an option from the UL drop down list.

Empty Function
onRollover - Function(data, $li, $ul)

Callback function when the user highlights one of the options of the UL drop down list.

Triggers

Auto-complete comes with a set of predefined event's that operate some common tasks. To trigger these events, use the normal autoComplete function initialization, with the string name of the event as the first parameter, along with any other parameters that are needed. Something like the following:
	$('selector of input').autoComplete('event name', ...other params...);

settings - Function('settings', newSettings)

The settings trigger allows for changes to the settings for that inputs autoComplete at any point of time. This can be very useful if the metadata plugin is not installed, yet separate functionality is needed for each input. Simply initiate the autocomplete on each input, and use the settings trigger to attach special parameters to each input's autoComplete instance.

Extra Functionality*: If you pass a funtion as the newSettings var, you can view that inputs current settings and cache, and adjust accordingly. Just return the array [newSettings, cache]. Here's the format:

$('input selector').autoComplete('settings', function(settings, cache){
	// ...Check or make changes to the current settings and cache here...
	return [settings, cache];
});


flush - Function('flush', cacheOnly)

The flush event clears out the inner cache of results, as well as the number of requests made. And optional, second boolean parameter can be passed if only the cache needs to be flushed, not the number of requests made.

destroy - Function('destroy', cacheOnly)

The destroy trigger unbinds that inputs autoComplete event's.

button.ajax - Function('button.ajax', postData, cacheName)

The button.ajax trigger allows for sending requests through an external trigger(button). It's recommended a special post var is passed to differentiate between a normal request and a triggered request. This can enable a sort of select drop down functionality, where clicking a button can show the whole list, or users can just use the autoComplete to find their selection.

button.supply - Function('button.supply', data, cacheName)

The button.supply trigger is essentially the same as the button.ajax trigger, except it works with a localized set of results instead of through an ajax requests. Additionally, an optional second data parameter can be passed to supply a different set of results on just this trigger, instead of the normal set supplied during initialization.