-
Notifications
You must be signed in to change notification settings - Fork 15
How to use autocomplete widget
Chandan Kharbanda edited this page Apr 3, 2015
·
2 revisions
$(input).autocomplete( url, displayName, idElem, idKey );
URL returning all the completion object in array of object form in JSON.
For example,
[{id: 1, val: 'hello'}, {id: 2, val: 'hey'}]
Which key to display and search in for autocomplete.
In our example, 'val'
If you want to submit or set id or some other field of selected element in some other input, pass the DOM element of other input here.
If you set idElem
, pass key for the value to be set in idElem
<input id='greet_id' name='greet_id'>
<input id='greet' name='greet'>
$('#greet').autocomplete(
url, // URL returning out example JSON
'name', // field to display and search
$('#greet_id'), // Element to set id in
'id' // Field for id
);