AutoComplete is a jQuery Mobile plugin which allows developers to add autoComplete search boxes to your project.
Based on the blog entry of Raymond Camden (@cfjedimaster).
View a simple demo of autoComplete
Clone the git repo - git clone git@github.com:commadelimited/autoComplete.js.git - or download it
$("#searchField").autocomplete({
target: $('#suggestions'), // the listview to receive results
source: 'data.cfc?method=search&returnformat=json', // URL return JSON data
link: 'testing.cfm?term=', // link to be attached to each result
minLength: 0 // minimum length of search string
});
AutoComplete.js can read data in one of two ways: simple or complex. Simple data should be returned from the source in the following format:
[
"Maine",
"Maryland",
"Massachusetts"
]
Causing the resulting code to look like this: <a href="testing.cfm?term=Maine">Maine</a>
Complex data allows the developer to specify which value goes where. AutoComplete.js requires data to be returned in a specific format:
[
{
value: "22",
label: "Maine"
},
{
value: "23",
label: "Maryland"
},
{
value: "24",
label: "Massachusetts"
}
]
Causing the resulting code to look like this: <a href="testing.cfm?term=22">Maine</a>
You are invited to contribute code and suggestions to this project. The more the merrier.
- Source: https://github.com/commadelimited/autoComplete.js
- Twitter: http://twitter.com/commadelimited
- Twitter: http://twitter.com/cfjedimaster
- jQuery: MIT/GPL license
- jQuery Mobile: MIT/GPL license
Public domain