=head1 NAME GvaScript.Autocompleter - autocompletion on form input fields =head1 SYNOPSIS In Javascript : var autocompleter1 = new GvaScript.Autocompleter( "http::/some/url", {minimumChars : 2, strict : true, onBind : doSomething, onLeave : doSomethingElse} ); var autoCompleter2 = new GvaScript.Autocompleter( ["foo", "bar", ...], options); var autoCompleter3 = new GvaScript.Autocompleter( [{label: "foo", value: "f", otherValue: 123}, {label: "bar", value: "b", otherValue: 456}, ...], options); var autoCompleter4 = new GvaScript.Autocompleter( myCompletionFunction, options); Then, in HTML : =head1 DESCRIPTION Component designed both as an "autocompleter" (anticipating further key events by users) and as a replacement for HTML C and user has typed C in the input field, then an Ajax request will be sent to C. The server should return a JSON array, in the format explained below. =item a callback function That function will be called, with the current value of the field as single argument. =item an array The array is taken as in-memory datasource. The returned suggestion list is either the complete array (when C is true) or just the list of items that are prefixed by the current value of the field. See also C. =item an object (JSONP) Useful when accessing data on a different domain via JSONP services. Ex : { json_url: 'http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&query=?1&output=json&callback=?2', json_list: 'ResultSet/Result' } The object should hold details of the JSONP service to be called. C : url to call with placeholders (?1, ?2) for value to look for and callback method respectively. C : path to the list in the json response =back =head3 Format of suggestions returned by datasources Datasources should return a list of suggestions in the form of a Javascript array (in case of Ajax requests, the response should be a JSON body containing a single array). For each suggestion in the array, the autocompleter needs a I