Am using .keyup to filter my auto complete.
However it only allows me to enter the first digit. so if my data is "Apple"
when i type A - it shows Apple but i cannot type "AP" as the "P" disappears.
I was expecting that i can write the whole word rather than the first letter.
Code:
<input id="ac" /> <span></span>
var validOptions = "@Url.Action("SerialProdNumStockSiteAutoComplete", "Ajax")?stocksitenum=LW&model=" + $("#Form_Prod_Num").val();
previousValue = "";
$('#ac').autocomplete({
autoFocus: true,
source: validOptions
}).keyup(function () {
var isValid = false;
for (i in validOptions) {
if (validOptions[i].toLowerCase().match(this.value.toLowerCase())) {
isValid = true;
}
}
if (!isValid) {
this.value = previousValue
} else {
previousValue = this.value;
}
});
This was working when i used dummy data, but when i changed this to url.action it only worked for the first letter rather than the whole word.
I do have a fiddle that works - however when i added my "URL.action" it only accepted the first letter. (There are about 5000 values)
var validOptions = "@Url.Action('SerialProdNumStockSiteAutoComplete', 'Ajax')?stocksitenum=LW&model=" + $("#Form_Prod_Num").val();
– HandclapGET http://fiddle.jshell.net/_display/@Url.Action('SerialProdNumStockSiteAutoComplete',%20'Ajax')?stocksitenum=LW&model=undefined&term=a 404 (NOT FOUND)
– Handclap