I think a little more monkey patches are fine:
thing.data("autocomplete")._response = function(content) { if (!this.options.disabled) { this._trigger("open"); content = this._normalize(content); this._suggest(content); } this.pending--; if (!this.pending) { this.element.removeClass("ui-autocomplete-loading"); } };
Example: http://jsfiddle.net/eJMuf/
This should work, but I will continue to look for a solution using the standard API.
Here's another solution that does not require the same open heart operation, but requires more code:
var thing = $("#thing").autocomplete({ minLength: 0, source: function(request, response) { var result = myArray.slice(0); result = $.ui.autocomplete.filter(result, request.term); result.push({ value: request.term, isPlaceholder: true }); response(result); } }).focus(function() { $(this).autocomplete("search", this.value); }); var renderItem = thing.data("autocomplete")._renderItem; thing.data("autocomplete")._renderItem = function(ul, item) { if (item.isPlaceholder) { return $("<li>") .data("item.autocomplete", item) .append("<a class='helper'>Add <b>\"" + item.value + "\"</b> as a new item</a>") .appendTo(ul); } else { renderItem(ul, item); } };
Example: http://jsfiddle.net/FvCY6/
I would personally go with this decision as it is less invasive.
source share