JQuery Autocomplete: formatItem not working

We spent a lot of time trying to get a remarkably simple script to work with (and everyone else seems to be successful). Finally, we want to create an autosuggest text field using JQuery, which writes the value of the selected text to a hidden field, but this is not a question because even the first step fails (but a working example of the code that relates to this is very welcome).

For some reason, the Item format (and other formatting functions) is not executed. What do we misunderstand?

Any help is much appreciated.

Here is the code (devoid of everything that is not needed for an example):

<html> <head> <title>Why o why?</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script> <script type="text/javascript"> $(function() { var s = ["a", "b", "ab"]; $("#txtSearch").autocomplete({ source: s, formatItem: function(row, i, n) { return "whatever" }, minLength: 1 }); }); </script> </head> <body> Search <input id="txtSearch" type="text" /> </body> </html> 

The autosuggest function as such works in any browser, but the browser does not launch formatItem.

+4
source share
1 answer

These methods are deprecated in the version that comes with the jQuery interface. Check out the migration guide to learn more about how you can now implement the old FormatItem, formatMatch, etc.

+10
source

All Articles