jQuery UI Autocomplete on KeyPress write value -


i trying implement jquery ui autocomplete way like
when have list "alpha","beta","gamma" type "a" input field
, "alpha" proposal want hit enter , "alpha" shall be
new value of input field instead of selecting "alpha" mouse click. possible?

$.ajax({      url   : 'myajax.php',      type  : 'post',     data  : { param: getdata },     datatype : 'json',     success  : function(data) {                            $("#myfield").autocomplete({              minlength: 0,                                    source: data,             focus: function( event, ui ) {                                       $(this).val(ui.item.key);                 return false;             },             select: function( event, ui ) {                  $("#myfield").val(ui.item.value);                  return false;             }                 });                  } }); 

you can add

autofocus: true 

this make focus on first element , when press enter automatically put label in field using

$("#myfield").val(ui.item.label);  

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -