How to show autocomplete jquery ui on textbox in html -


this code: getting values ajax , showing autocomplete. tried lot of solutions in stackoverflow. didn't this. please 1 me recover this:

   $(document).on("change", "#selectbox-city-list2", function(){         $("#inputarea").val('');         $("#inputareactrl").val('');         $.ajax({             url: "<?= base_url ?>/shop/area.html",             type: "get",             data: {city_key: $("#selectbox-city-list2").val()},             datatype: "json",             success: function(data){                 $options = [];                 $.each(data, function(i, field){                     $option = {"label":field.location, "value": field.area_key};                     $options.push($option);                 });                  $("#inputarea").autocomplete({                     source: $options,                     select: function(event, ui){                         $("#inputarea").val(ui.item.label);                         $("#inputareactrl").val(ui.item.value);                         return false;                     }.focus(function(){                         if($("ul.ui-autocomplete").is(":hidden"))                         {                             $(this).autocomplete('search', ''); //tried                              $("ul.ui-autocomplete").show(); //tried                            //but no luck                         }                     });                 });             },             error: function(xhr, error, status){                 alert(status);             }         });     }); 

thanks in advance

i got answer added minlength: 0 in autocomplete function

   $("#inputarea").autocomplete({                     source: $options,                     select: function(event, ui){                         $("#inputarea").val(ui.item.label);                         $("#inputareactrl").val(ui.item.value);                         return false;                     },                     minlength: 0                 }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -