I\'m using jQuery\'s autocomplete in a relatively simple way:
$(document).ready(function() {
var data = [ {text: \"Choice 1\"},
{text: \"Ch
I have seen all the answers which seem to be complete.
If you want to get the list when the cursor is in the text field OR when you click on the matching label, here how you can do:
//YourDataArray = ["foo","bar"];
$( "#YourID" ).autocomplete({
source: YourDataArray
}).click(function() { $(this).autocomplete("search", " "); });
this works fine in Firefox, IE, Chrome ...
I guess a better option is to put $("#idname").autocomplete( "search", "" ); into the onclick paramter of the text box . Since on select, a focus is put in by jquery , this can be a workaround . Dont know if it should be an acceptable solution.
I used this way:
$("#autocomplete").autocomplete({
source: YourDataArray,
minLength: 0,
delay: 0
});
Then
OnClientClick="Suggest(this); return false;"/>
function Suggest(control) {
var acControl = $("#" + control.id).siblings(".ui-autocomplete-input");
var val = acControl.val();
acControl.focus();
acControl.autocomplete("search");
<input type="text" name="q" id="q" placeholder="Selecciona..."/>
<script type="text/javascript">
//Mostrar el autocompletado con el evento focus
//Duda o comentario: http://WilzonMB.com
$(function () {
var availableTags = [
"MongoDB",
"ExpressJS",
"Angular",
"NodeJS",
"JavaScript",
"jQuery",
"jQuery UI",
"PHP",
"Zend Framework",
"JSON",
"MySQL",
"PostgreSQL",
"SQL Server",
"Oracle",
"Informix",
"Java",
"Visual basic",
"Yii",
"Technology",
"WilzonMB.com"
];
$("#q").autocomplete({
source: availableTags,
minLength: 0
}).focus(function(){
$(this).autocomplete('search', $(this).val())
});
});
</script>
http://jsfiddle.net/wimarbueno/6zz8euqe/
I found this to work best
var data = [
{ label: "Choice 1", value: "choice_1" },
{ label: "Choice 2", value: "choice_2" },
{ label: "Choice 3", value: "choice_3" }
];
$("#example")
.autocomplete({
source: data,
minLength: 0
})
.focus(function() {
$(this).autocomplete('search', $(this).val())
});
It searches the labels and places the value into the element $(#example)
$("#searchPkgKeyWord").autocomplete("searchURL",
{
width: 298,
max: 1000,
selectFirst: false
}).result(function (event, row, formatted) {
callback(row[1]);
}).focus(function(){
$(this).click(); //once the input focus, all the research will show
});