Yes, you can extend the behavior of script.aculo.us autocompleter. You do this by overriding the onComplete method with code that processes the json data and creates an <ul> -list for it. Then this list should be sent to updateChoices .
Suppose you get the following JSON response when you search for "U":
[ "Unicorn", "University" ]
An example of the Ajax.Autocompleter extension that can handle the answer above:
var MyCompleter = Class.create(Ajax.Autocompleter, { initialize: function($super, id_search, id_list, url, options) { $super(id_search, id_list, url, options); }, onComplete: function(response) { var text = response.responseText; if (text.isJSON()) { this.handleJSON(text.evalJSON()); } // else do nothing }, handleJSON: function(json) { var htmlStr = '<ul>'; json.each(function(item) { htmlStr += '<li>'; htmlStr += item; htmlStr += '</li>'; }); htmlStr += '</ul>'; this.updateChoices(htmlStr); } });
There is also an example of how to replace the auto-assembly width reset .
Spike source share