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
Post a Comment