Auto input complete plugin with jQuery.
jQuery and jQuery.textchange is required, so include it first. Also Font Awesome required if you want use plugin without own icons Include the script in your HTML file:
<script src="../auto_inputbox.js"></script>
$('#user-input').autoInput({
url: 'https://jsonplaceholder.typicode.com/users',
options
});
Where 'options' is an optional parameter.
The default options
are:
{
icon: 'myautoInputIcon',
className: 'autoInput',
closeIcon: 'fa-times-circle',
loadingIcon: 'fa-spinner fa-pulse',
nothingFoundMessage: 'Nothing found',
formatElement: function(el) {
return JSON.stringify(el).substring(20);
},
onItemSelected: function(el) {
return $(el).html();
},
slideDownComplete: function() {
},
onSubmit: function(event, value) {
},
getRequestPath(input) {
return '/' + input;
}
}
Where
className
- name of css classes prefixcloseIcon
- name of css style with icon for erase input boxloadingIcon
- name of css style with icon for loading datanothingFoundMessage
- message for users when elements not foundformatElement
- function that map elementsonItemSelected
- function that return value that will be stored in input tag and submitedslideDownComplete
- function for actions onslide complete
onSubmit
- event of form submitgetRequestPath
- methods for forming params of request