Autofill
description |
Input Autocomplete |
type |
javascript |
source |
src/dvc/js/autofill.js |
inspired by jquery-ui and should behave as such
Example
<input type="text" name="name" id="name">
$('#name').autofill({
source : ['david', 'bill', 'mary']
});
or ...
a ajax request can be sent, the request is passed in the format
[<jsonObject>.term]
and the response is expected
[{'label':'David','value':'David'},{'label':'Bill','value':'Bill'}]
$('#name').autofill(
source : ( request, response) => {
_.post({
url : _.url(''),
data : {
action : 'search',
term : request.term
},
}).then( d => response( 'ack' == d.response ? d.data : []));
},
select : (e,ui) => {
/**
* by default the data is populated to the field,
* but additional processing can be done here
*/
}
);