I'm using the jQuery UI
AutoComplete
Combobox
option as illustrated here. This will start filtering the shown results immediately when you begin typing, but if an element is already selected, then typing (without manually removing the contents) will just append onto the string and typically not find anything.
I'd like the text to be selected by default whenever the input field receives focus, but am having trouble figuring out where to add that logic into the script.
Here's a jsFiddle with this example on it.
Normally, to select the text in an input element when it recieves focus, you could execute the following, like in this SO question:
<!-- language: lang-js -->//Select all text in Cost Rate Text Boxes when they have focus
$(document).ready(function () {
$(".CostRateTextBox").live('mouseup', function () {
$(this).select();
});
});
The _createAutocomplete
function in the script is where the input box is created. Is it possible to do this near the following line?
this.input = $("<input>")