I\'m working with mutiple jquery-ui autocomplete widgets on one page and want to be able to set the widths of each one individually. Currently, I\'m doing it like this:
If you have multiple controls that use autocomplete, a reasonably elegant solution is to retrieve the widget attached to the control at the last moment and modify its CSS:
$(document).ready(function() {
$("input#Foo").autocomplete({
source: source
});
$("input#Bar").autocomplete({
source: source,
open: function(event, ui) {
$(this).autocomplete("widget").css({
"width": 400
});
}
});
});
View Demo.
As mentioned above, the width of autocomplete list is calculated at the very last moment hence you must modify it in the open event.