I need autocomplete in the application I'm working on, and since I'm already using the jQuery user interface, I am trying to make the Autocomplete widget fit my needs.
Step one is to make the search query a match only at the beginning of the proposed conditions. I already have this work, as you can see in the code below. The second step is for the first sentence to be virtually autocomplete.
Which probably needs a little explanation. When I hear โautocompleteโ, I suppose to enter โfโ and change the contents of the text field to โfooโ, selecting โooโ so that it will be replaced if I type in another character and leave it in the if field. I exit it. I usually call what the Autocomplete widget offers, not autocomplete.
After seeing how Autocomplete works, I think the autocompleteopen event is the right place to do this (it is called every time the list of offers is updated), but I donโt understand how to access the list of offers from there.
Any thoughts?
$("#field").autocomplete({ delay: 0, source: function filter_realms(request, response) { var term = request.term.toLowerCase(); var length = term.length; response($.grep(candidates, function(candidate) { return candidate.substring(0, length).toLowerCase() === term; })); }, open: function(event, ui) {
jquery jquery-ui autocomplete
Ben blank
source share