Skip to content

Instantly share code, notes, and snippets.

@rupe120
Created March 29, 2017 13:53
Show Gist options
  • Save rupe120/bc520aaac48608b0c3d825d13dda6deb to your computer and use it in GitHub Desktop.
Save rupe120/bc520aaac48608b0c3d825d13dda6deb to your computer and use it in GitHub Desktop.
autoComplt with AJAX
function initializeLeadUserInput() {
var autoCompleteInput = document.getElementById('auto-complete-input');
window.autoComplt.enable(autoCompleteInput, {
hintsFetcher: function (text, openAutocompleteList) {
$.ajax({
url: '/getautocompletelist',
type: 'post',
data: { search: text },
dataType: 'json',
success: function (data) {
// openAutocompleteList() expects an array of strings,
// so you may need to do some transformation here to
// capture object IDs and only pass along an arry of
// display strings
openAutocompleteList(data);
}
});
}
});
}
@rupe120
Copy link
Author

rupe120 commented Mar 29, 2017

This uses the https://github.com/Fischer-L/autoComplt library, which doesn't modify the DOM around the input nor use jQuery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment