jquery - autocomplete json data - how can I use it in MVC3 Razor -


when jquery autocomplete function gets json data items, how can take selected item , assign them other textboxes in dom?

do wire event in textbox?

my js:

$(document).ready(function () { $("#custbyname").autocomplete(     {         source: function (request, response) {             $.ajax(             {                 url: "/cases/findbyname", type: "get", datatype: "json",                 data: { searchtext: request.term, maxresults: 10 },                 contenttype: "application/json; charset=utf-8",                 success: function (data) {                     response($.map(data, function (item) {                         return {                             label: item.customername,                             value: item.customername,                             id: item.customerid                         }                     })                     );                 }             });         },         minlength: 3     });  }); 

and controller action:

//post: autocomplete customer names     //[httppost]     public jsonresult findbyname(string searchtext, int maxresults)         {         customerfind find = new customerfind();         var result = find.findcustomerbyname(searchtext, maxresults);         return json(result, jsonrequestbehavior.allowget);         } 

and findcustomerbyname function

internal list<models.customer> findcustomerbyname(string searchtext, int maxresults)         {         list<models.customer> result;          using (cummins_sqldb datacontext = new cummins_sqldb())             {              result = (from c in datacontext.customers                       c.customername.contains(searchtext)                       orderby c.customername                       select c).take(maxresults).tolist();             }         return result;          } 


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -