jquery - Autocomplete using JSON -


in view have

@html.textboxfor(per => per.hospital, new {      style = "width:220px", @maxlength = "50",      data_autocomplete = url.action("hospitallist", "person") }) 

my jquery is

$(document).ready(function () {             $('input[data-autocomplete]').each(function () {         var url = $(this).data('autocomplete');         $(this).autocomplete({             source: function (request, response) {                 $.getjson(url, {                     term: request.term                 }, response);             }         });     }); }); 

and created new action result

public actionresult hospitallist(string term) {     list<string> result = new list<string>();     result.add("hospital 1");     result.add("nyumc");     result.add("christ");     result.add("bellevue");     result.add("newyork-presbyterian");     result.add("north central bronx hospital");         result = result.where(r => r.contains(term)).tolist();               return json(result , jsonrequestbehavior.allowget); }   

i included jquery library

<script src='<%: url.content("~/scripts/jqueryui/jquery-1.4.2.min.js") %>'    type="text/javascript"></script>   <script src='<%: url.content("~/scripts/jqueryui/jquery-ui-1.8.2.custom.min.js") %>'  type="text/javascript"></script> 

now going wrong. see a text box , no behavior of auto complete.

the jquery ui team did not add support jquery 1.4.3 until version 1.8.6 of ui (see here). therefore, although may have other issues going on, have potential library incompatibility.

upgrade versions of both libraries , see takes first.

http://jquery.com/download/ http://jqueryui.com/download/ or https://developers.google.com/speed/libraries/devguide#jquery

i hope helps.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -