Contains a global object of the autoComplete settings. Both of the settings passed into the autoComplete function as a parameter and defined through metadata solution overwrite these global defaults.
Number of element's on the page that currently have autoComplete attached to them.
This function gets triggered whenever one of the autoComplete inputs gains focus. It's treated exactly like the instance specific focus event, only it tracks all inputs. The this references the element currently in focus. The function gets two arguments passed in, the first is the event object that was triggered, the second is a ui object.
Note*: This function gets triggered across all inputs. For a per instance focus function, check out the onFocus event.
This function gets triggered whenever one of the autoComplete inputs loses focus. It's treated almost the same as the instance specific blur event, only it tracks all inputs. The this references the element currently losing focus. The function gets two arguments passed in, the first is the event object that was triggered, the second is a ui object.
Note*: This function gets triggered across all inputs. For a per instance blur function, check out the onBlur event.
Boolean key which is true when an input that has autoComplete attached is in focus, false otherwise.
Returns the element that is currently in focus. Passing true as an argument returns the jQuery cached version of that element. If no element is in focus, the function returns an empty jQuery object if a true argument is passed in, otherwise it returns undefined.
Returns the element that was previously in focus. Passing true as an argument returns the jQuery cached version of that element. If no element was previously in focus, the function returns an empty jQuery object if a true argument is passed in, otherwise it returns undefined.
Returns a jQuery object containing all elements that currently have autoComplete attached to them.
Contains the current version of the autoComplete plugin
The jQuery.autoComplete comes with a few more key variables that are operated on internally. Adjusting
these value's is generally a bad idea, but if required, here are the docs:
-counter: Index counter. Gives a unique id to each element internally.
-stack: Object containing all element's with autoComplete attached to them, referenced by their unique id.
-jqStack: Object containing all cached jQuery element's with autoComplete attached to them, referenced by their unique id.
-order: Array containing list order of each element focus event.
-keys: A list of keycodes used throughout the plugin.
-arrayMethods: Object containing all methods that may take an array as their first argument.
-handlerMethods: Object containing all methods that may use triggerHandler under the proper number of arguments
(-1 forces triggerHandler method regardless the number of arguments).
-remove: Function that removes an input from the stack, takes the element's unique id as the parameter.
With version 5.0 and going forward, autoComplete will become more jqueryui standards compliant for event driven functions. With that,
the parameter's passed to those functions have changed. To respect developers who are currently on 4.1, a backwardsCompatible setting
has been implemented to ensure parameters passed to those functions remain constant. This is to ease the transition into 5.0 and beyond.
From 5.0 and on, autoComplete will be using this style so new feature's can easily be implemented while still be compatible with earlier versions.
URL of the server side script.
Note*: When dataSupply has a length greater than 0, no ajax request is sent.
Whether to allow browsers to cache ajax requests. Default's to jQuery's native settings.
Automatically fills the input with the focused list item. Best to use with a delay, as it's prone to quirks with fast typers.
Only valid when bgiframe plugin is installed, this object gets passed as the settings argument into the bgiframe plugin.
Limit's the number of entries stored in cache. Setting this value to -1 will remove any limitation.
Note*: The global jQuery.autoComplete.defaults.cacheLimit value is used in determining the stack limit of the jQuery.autoComplete.order list.
Personal function to use in place of default pattern matching. Return true for correct match, false for incorrect.
Note*: with the backwardsCompatible flag enabled, the params are:
Function(search, entry, list, i, supply, ul, event, settings, cache).
Array of values/objects to run auto-complete as local instead of ajax requests. Default pattern match is: "/^(input value)/i"
Time delay of when to send the ajax requests in milliseconds.
Gives full access to formatting a supplied set of data into a list to be displayed.
Note*: An array of objects must be returned (Same array of objects format sent back from an ajax request).
inputControl provides access to changing the name for cache storage. When doing pattern matching, or sending requests, the string returned by this function is used.
Note*: This function must return a string, which is either the 'val' key of the ui object or a modification of it.
Note2*: with the backwardsCompatible flag enabled, the params are:
Function(val, key, ul, event, settings, cache).
CSS Class that will be attached to the UL created.
Limits the number of values added to the drop down list. When -1, no limit is imposed.
Applies the max-height logic programmatically for browser's that don't support that css property.
Maximum number of ajax requests allowed within a scripts duration. If 0, no limit is applied
The blocker setup by maxRequests only prevents more ajax requests from being made, while lists stored in the cache and supplied through dataSupply will still work. By setting this value to true, all requests are blocked.
Minimum number of required characters to send a request.
When true, multiple word searching is allowed.
Separator used between multiple words. Default's to an empty space, and is only active when the multiple option is true.
Defines whether to create a new UL drop down list for this instance, or use an existing one.
Array of character key codes not allowed. Remember to use keyCode's, not characters. By default, the shift, left arrow and right arrow keys are ignored.
Parameters that get passed to the server. The value defined by postVar will be overridden by the users input.
Format the data to be passed with the jQuery.ajax function when defined.
Note*: The function defined must return either an object or a string that conforms to the data option in jQuery.ajax.
Name of the users input as it gets posted to the server.
Prevents form submission when user selects a value from the UL drop down list using the enter key. This setting has been defaulted to true to conform to IE quirkiness. If the application requires form submission on enter, set this value to false to perform like so.
Type of request during ajax calls. Only use 'GET' or 'POST'.
CSS Class toggled on li elements when mouseover or up/down events occur.
CSS Class toggled on alternating li elements to give a zebra striped look.
Tells autoComplete whether or not to use script level caching.
Width of the UL drop down list. Default's to the width of the Input field
Callback function when the user loses focus on the input field.
Note*: with the backwardsCompatible flag enabled, the params are:
Function(val, ul, event, settings, cache).
Callback function when the user focuses on the input field.
Note*: with the backwardsCompatible flag enabled, the params are:
Function(ul, event, settings, cache).
Callback function whenever the drop down list is closed.
Callback function to format the list elements into the ul drop down.
Note*: You must populate the drop down list when defining this function.
Callback function before the drop down list is loaded.
Note*: You must return the list array, with or without modifications made.
Callback function when maximum number of ajax requests is reached. Will only fire if maxRequests is not 0.
Note*: with the backwardsCompatible flag enabled, the params are:
Function(search, ul, event, val, settings, cache).
Callback function when the user focuses on one of the li elements in the UL drop down list.
Note*: with the backwardsCompatible flag enabled, the params are:
Function(data, li, ul, event, settings, cache).
Callback function when the user selects an option from the UL drop down list.
Note*: with the backwardsCompatible flag enabled, the params are:
Function(data, li, ul, event, settings, cache).
Callback function when the drop down list is opened.
Callback function called when form submission occurs. If preventEnterSubmit is enabled, the onSubmit method will only fire when the drop list is not active.
Callback function used to let developers know when to activate and deactivate any spinner's they want to run during requests.
$('selector of input').autoComplete('method name', ...other params...);
The button-ajax method allows for sending requests through an external trigger(button). It's required to pass a special cacheName string if more than one button-ajax method is used on the same input. If only one is used, an inner string of random characters will be used. 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.
The button-supply method is essentially the same as the button-ajax method, except it works with a localized set of results instead of through ajax requests. Additionally, an optional second data parameter can be passed to supply a different set of results on just this event, instead of the normal set supplied during initialization. Also, if more than one method is in use for the same input, it is required to pass different cacheName's so caching of the data-set's don't override each other.
Destroys the autoComplete initiation. Removes all events and data that were attached to the input, form, and document. Also, if the UL drop list was created through the function, and no other input's are using it, that element will be removed as well.
The direct-supply method bypasses list formatting and request delays, and loads either the data supplied to it, or the dataSupply data. This would be the fastest way to load a list directly into the drop down UL, but is prone to errors if the data passed to formatted incorrectly.
Disables the autoComplete, but doesn't destroy it.
Enables the autoComplete.
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.
The option method provides a way to get/set single settings.
-Passing both name and value parameters will set that option into the current settings.
-Passing just the name value returns that settings value. There are four keywords that return special objects:
-Passing 'ul' will return the $ul object for the drop down list
-Passing 'cache' will return the current cache object
-Passing 'xhr' will return the last called xhr request
-Passing 'input' will return the current $input object.
-Passing no name or value parameter's will return the entire settings object.
Note*: Not passing the value parameter breaks the chain, as it utilizes jQuery's triggerHandler option to return the value return from the event function.
The search method gives a programmatic way for triggering search with custom input. The 'value' parameter passed should contain a string for the custom search to be triggered.
The settings method 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 method to attach special parameters to each input's autoComplete instance.
Extra Functionality*: If a function is passed as the newSettings var, the inputs current settings and cache are passed to the function as parameters. Just return the array [newSettings, cache]. Here's the format:
$('input').autoComplete('settings', function(settings, cache){ // ...Check or make changes to the current settings and cache here... return [settings, cache]; });