Open GioLogist opened 8 years ago
I've added modifications, that allows you to change match method. I've prepared jsfiddle with example: https://jsfiddle.net/s42jj5p5/
I didn't released code, so you need to use plugin files from "dist" folder https://github.com/pawelczak/EasyAutocomplete/tree/master/dist
hello pawelczak sir, I didn't got this example please elaborate .. https://jsfiddle.net/s42jj5p5/ I have same situation , and want to search as @GioLogist asked ... thank you
It may be too late but I found a issue :
On line 654 of js change :
value.search(phrase) > -1
to
value.lastIndexOf(phrase,0) === 0
Changing line 46 to:
if (a === b){ return 1; }
and 63 to:
if (element.search(phrase) === 1)
in jquery.easy-autocomplete.js appears to search as per @GioLogist requested.
@rcatwr i tried but isnt working, if you use for example you will notice that isnt bring the data that starts with "FR", im searching by "label", and the final result im looking for is "FR Ryanair" , list example: http://www.json-generator.com/api/json/get/cdLxcejibm?indent=2
@bonucci -- leave 45 as:
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
try changing line 65 to:
if (element.search(phrase) === 0) {
return true;
} else {
return false;
}
In case if someone would need this for later while initiating easyAutoComplete, pass this as an option;
list: {
match: {
method: function(element, phrase) {
return (element.lastIndexOf(phrase, 0) === 0);
}
}
}
And you don't need to edit any source code as this is a bad practice and there is a solution for this.
Is it possible to make it only autocomplete based only on the first letter(s) typed?
IE: Right now it searches based on '%A%' instead of 'A%', so if I type "A" i get both "Ants" and "Panda", my aim is to only get "Ants".