The width of the reset in the autocomplete list automatically using the Base.Autocompleter implementation. Base.Autocompleter set the list to have the same width as the search input field. There are several ways around this:
1. Patch Autocompleter.Base yourself
You can fix Autocompleter.Base script yourself as described in this post . For script.aculo.us version 1.8.1 in controls.js on line 68 you have the following:
Position.clone(element, update, { setHeight: false, offsetTop: element.offsetHeight });
Add setWidth: false to this parameter object as follows:
Position.clone(element, update, { setWidth: false, setHeight: false, offsetTop: element.offsetHeight });
2. Expand your autorun
The following is an example of the Ajax.Autocompleter extension. The idea is to replace the onShow function that the base class will call to show autocomplete and resize it using Position.clone() .
var MyAutocompleter = Class.create(Ajax.Autocompleter, { initialize: function($super, id_for_search, id_for_list, url) { $super(id_for_search, id_for_list, url, { onShow: function(element, update) { if(!update.style.position || update.style.position=='absolute') { update.style.position = 'absolute'; Position.clone(element, update, { setHeight: false, setWidth: false, offsetTop: element.offsetHeight }); } Effect.Appear(update,{duration:0.15}); } }); } });
And you create it as usual with new just like with other autocomplete classes.
document.observe("dom:loaded", function() { new MyAutocompleter('search', 'autoList', 'url/for/ajaxcall'); });
The advantage of the latter is that you can upgrade the version of script.aculo.us without reloading the files, and you can continue to overload and extend Autocompleter to your liking (given that you know how the base class behaves).