I have a auto complete box set up.
however when a user types in the box a list of every single item appears.
Not relating to anything the user is typing in.
What am i doing wrong?
Jquery:
var availableTags = '@Url.Action("PopSearch", "Home")';
$("#searchtxt").autocomplete({
source: availableTags
});
Controller function:
public ActionResult PopSearch()
{
IndustryManager manager = new IndustryManager();
ProductRangeManager manager2 = new ProductRangeManager();
ProductCategoryManager manager3 = new ProductCategoryManager();
IList<Industry> industryList = manager.GetIndustries();
IList<ProductRange> rangeList = manager2.GetAllProductRanges();
IList<ProductCategory> categoryList = manager3.GetAllProductCategories();
var attributes = industryList.Select(x => x.Name)
.Union(rangeList.Select(x => x.Name))
.Union(categoryList.Select(x => x.Name)).ToArray();
return Json(attributes, JsonRequestBehavior.AllowGet);
}
Check the server request. Probably you have a request to the server something like
http://yoursite.com/Home/PopSearch?term=Something
Where something is what user inputs in the textbox. It means that you need to filter it on the server side and return already filtered data.