0

The default behavior of the jqueryui autocomplete is the input field to be empty and to start listing data when the user starts typing(Even the minLength is set to 0). I want all the data to be listed as a dropdown in the beginning so the user can see all the available options. Is that possible

js file

$("#unique_code").autocomplete({
    source : "php/autocomplete_getunique_code.php",
    minLength: 0,
    select: function( event, ui ) {
    }
});

Im echoing all available data in autocomplete_getunique_code.php, but it works after start typing only. how can i achieve it, that show all available result when focusing

  • possible duplicate of [Jquery UI autocomplete; minLength:0 issue](http://stackoverflow.com/questions/4604216/jquery-ui-autocomplete-minlength0-issue) – Shai Feb 11 '14 at 17:53

2 Answers2

0

Have you tried minChars:0?

   $("#unique_code").autocomplete({
        source : "php/autocomplete_getunique_code.php",
        { minChars: 0 }
    });
ltalhouarne
  • 4,586
  • 2
  • 22
  • 31
0

You could try manually firing a search onFocus

$("#unique_code").autocomplete({
    source : "php/autocomplete_getunique_code.php",
    minLength: 0
}).focus(function(){ 
    $(this).data("autocomplete").search($(this).val());
});
Louis Huppenbauer
  • 3,719
  • 1
  • 18
  • 24
  • Its working superb, but the active value is not replacing i think. –  Feb 11 '14 at 18:07
  • When yo click on an element? – Louis Huppenbauer Feb 11 '14 at 18:08
  • no, its replace in input box, but with using select function select: function( event, ui ) { } $( "#unique_code" ).on( "autocompleteselect", function( event, ui ) { var unique_code = $("#unique_code").val(); alert(unique_code); –  Feb 11 '14 at 18:11