Created
March 29, 2017 13:53
-
-
Save rupe120/bc520aaac48608b0c3d825d13dda6deb to your computer and use it in GitHub Desktop.
autoComplt with AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses the https://github.com/Fischer-L/autoComplt library, which doesn't modify the DOM around the input nor use jQuery