javascript - Passing additional data through my JSON object,that is returned from the auto complete -


I am working on an ASP.NET MVC web application. I have the following action method, which will return tag numbers as JSON to display as a full-time result: -

  public functioning autocomplete (string word) {var ad = Repository.FindServer (term, true). Oderby (p => P. technology.tag). Select (A = & gt; new {label = A.Technology. Tag}). ToList (); Return Jason (Advertising, Jesenfest Behavior Alove Gate); }  

and my auto complete area is:

  & lt; Text & gt; Search & lt; / Text & gt; & Lt; Input placeholder = "search by tag" name = "search term" data -auto-source = "@ Url.Action" (auto-complete "," rack ")" type = "article" class = "search_orggin" & Gt;  

But I added additional data such as "server name and data" in addition to the current tag number, back as part of Jason But to auto-complete based on the tag number.

I'm looking for something like auto complete results inside Facebook where you type a name, you'll find a person network & amp; Country, so you can know which people we want. Regards

edit is the action method: -

  public functioning autocomplete (string word) {var tech = repository.AllFindTechnolog (term ) to list(); Var Resources = Repository Gate Resources (Select Tech (A = & gt; a.IT360ID.Value) .Oire (), False) .OolIS (); Var query = Technology among the resources that connects to tectonics. IT 360 looks at resources on ID. Value is equal to resources. Based on ITES .RESOURCEID // db2ID, select new {label = techItems.Tag, name = resourcesItems.RESOURCENAME}; Return Jason (Query, Jasonyurefesti Bihari. Allo Gate); }  

I think how much functionality you get after you get the required functionality You can do this with javascript so that you can use the function. Something like this:

  $ (document) .ready (function () {$ .get ('rack / autocomplete', function (data) {$ ('input [name = "searchTerm "] '. (Auto-integer) () {autocomplete ({minLength: 0, source: data, create: function () {$ (this). Autocomplete (' example ') ._render item = function (ul , Item) {return $ ('
  • ') .append ('& lt; a & gt;' + item.label + '& lt; br & gt;' + item.name + '& Lt; br & gt; + item.label + '& lt; / a & gt;') .appendTo (UL);}}}});});});
  • < P> This is working on it.

    For older versions of jQuery:

      create: function () {$ (this). Data ("ui- Autocomplete ") ._ Returned M = function (ul, item) {return $ ('
  • gt;' app '(' & lt; a & gt; '+ item.label +' & lt; br & gt; '+ item Name * '
  • or old :

      create: function () {$ (this) .data ("autocomplete"). RenderItem = function (ul, app ('& lt; a & gt;' + item Label + '& lt; Br> + Item.name + '& lt; Br> + Item.label + '& lt; / A & gt; ') .appendTo (UL); }; }  

    Comments

    Popular posts from this blog

    Member with no value in F# -

    java - Joda Time Interval Not returning what I expect -

    c# - Showing a SelectedItem's Property -