How to use it
Obviously, you need to make sure that you have the latest jQuery library (at less than 1.3) already loaded on your page. After that, it's really simple, just add the following code to your page (be sure to wrap your code in the jQuery ready function):
$(function(){ $("input[type=text]").autoSuggest(data); });
The line of code above applies AutoSuggest to the entire text type of the input elements on the page. Each of them will use the same data set. If you want to have multiple AutoSuggest fields on your page that use different datasets, make sure you select them separately. like this:
$(function(){ $("div.someClass input").autoSuggest(data); $("#someID input").autoSuggest(other_data); });
Doing the above allows you to pass in various parameters and various data sets. The following is an example of using AutoSuggest with a Data Object and various other options:
var data = {items: [ {value: "21", name: "Mick Jagger"}, {value: "43", name: "Johnny Storm"}, {value: "46", name: "Richard Hatch"}, {value: "54", name: "Kelly Slater"}, {value: "55", name: "Rudy Hamilton"}, {value: "79", name: "Michael Jordan"} ]}; $("input[type=text]").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name"});