I am using a jquery autocomplete with combobox nabled. I want to show an empty option however whenever I set the value of my initial selection to an empty string it is not shown in the combobox.
The item is present it just contains no height.
Is it possible to have a blank option on an autocomplete combobox ?
$("#ctrl").autocomplete({
source: [ "\u00A0", "One", "Two" ]
});
So we figured out the solution. You need to work with the _renderItem
method.
input.data("autocomplete")._renderItem = function(ul, item) {
var listItem;
if (item.label == "<strong></strong>") {
listItem = $("<li></li>")
.data("item.autocomplete", item)
.append("<a><br></a>")
.appendTo(ul);
} else {
listItem = $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
}
return listItem;
};
Take note that you must have a blank string item in your initial list for this to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With