in Education by
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 industryList = manager.GetIndustries(); IList rangeList = manager2.GetAllProductRanges(); IList 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); } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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. public ActionResult PopSearch(string term) { IndustryManager manager = new IndustryManager(); ProductRangeManager manager2 = new ProductRangeManager(); ProductCategoryManager manager3 = new ProductCategoryManager(); IList industryList = manager.GetIndustries(); IList rangeList = manager2.GetAllProductRanges(); IList categoryList = manager3.GetAllProductCategories(); var attributes = industryList.Select(x => x.Name) .Union(rangeList.Select(x => x.Name)) .Union(categoryList.Select(x => x.Name)).ToArray(); var result = attributes.Where(x => x.ToLower().StartWith(term.ToLower())); return Json(result, JsonRequestBehavior.AllowGet); }

Related questions

0 votes
    I have a auto complete box set up. however when a user types in the box a list of every single ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I'm playing around with ASP.net MVC and JQuery at the moment. I've come across behavour which ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am currently trying to create an autocomplete with a source that is stored in a javascript variable but ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I want to build a jquery Auto Complete input field for the city the user stays in. When the user ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    I have an autocomplete that's almost working as I want it to work. The problem that I have is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have an autocomplete that's almost working as I want it to work. The problem that I have is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I'm attempting to automate a payment system, where the "Pay with PayPal" button is within an iFrame. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 9, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 6, 2022 in Education by JackTerrance
0 votes
    I was reading the great article about binding and unbinding events (because I am a js beginner using jQuery ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I am building a basic RSS reader app that, which the 'story' is clicked, the information for it is displayed in a modal ... .log('Does Not Work!'); Or another way: - overscroll...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    In which type of networks training is completely avoided? (a) GRNN (b) PNN (c) GRNN and PNN (d) None of the mentioned Please answer the above question....
asked Aug 27, 2022 in Education by JackTerrance
0 votes
    ............ are neither completely military forces nor completely civil forces. (a) Border Security Forces (b) ... Coast Guards (d) Home Guards Please answer the above question....
asked Aug 16, 2022 in Education by JackTerrance
...