javascript - Jquery Autocomplete Suggestion after first character -


i'm trying jquery autocomplete populate , display menu after first character, current code doesn't this. works after second character entered , works when delete entered characters. thoughts?

$("#resource").keyup(function(){     var s = $("#resource").val();     $( "#resource" ).autocomplete({ minlength: 0 });     $.post("url_to_php_script_json_data_returned",         {search:s},         function(data,status){             if (status == 'success') {                 var obj = json.parse(data);                 var availabletags = [];                 if (obj.length > 0) {                     var tags = [];                     (var = 0; < obj.length; i++) {                         var name = obj[i]['last_name']+', '+obj[i]['first_name'];                         var u_id = obj[i]['user_id'];                         availabletags.push( {value:name,label:name,rid:u_id} );                     }                 }                 $("#resource").autocomplete({                     minlength: 0,                       source: availabletags,                       focus: function( event, ui ) {                           $("#resource").val( ui.item.label );                           $("#rid").val( ui.item.rid );                           return false;                       },                       select: function( event, ui ) {                           $("#resource").val( ui.item.label );                           $("#rid").val( ui.item.rid );                           return false;                       }                 });             }         }     ); }); 


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -