Created
September 10, 2010 21:24
-
-
Save atzkey/574398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
jQuery UI Autocomplete AutoFill extension | |
automatically fills in the input box when only one suggestion is to be shown | |
*/ | |
;(function($) { | |
$.extend($.ui.autocomplete.options, {autoFill: true}); | |
$.extend($.ui.autocomplete.prototype, { | |
_response_original: $.ui.autocomplete.prototype._response, | |
_response: function(content) { | |
if (this.options.autoFill && content.length == 1) { | |
content = this._normalize(content); | |
this.element.val(content[0].value); | |
this.close(); | |
this.element.removeClass("ui-autocomplete-loading"); | |
return; | |
} | |
this._response_original(content); | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment