json - Jquery AutoComplete Shows all list Instead of search result -
i have jquery autocomplete source of json :
$(function () { $('body').delegate('input.city', 'focusin', function () { $(this).autocomplete({ source: function (request, response) { response($.map(json.parse(cityjs), function (item) { return { label: item.cityname, value: item.cityid }; }))}, minlength: 3 }); }); }); });
now when search in box shows label results in list instead of auto complete. when use method :
var availabletags = ["...some content,some content..."]; $('body').delegate('input.city', 'focusin', function () { $(this).autocomplete({ source: availabletags }); });
it works. problem need id of selected value box.
cityjs json array comes in model pair of cityid , cityname. cityjs sample :
[{"cityid":7,"cityname":"aaa"}, {"cityid":6,"cityname":"bbb"}, {"cityid":5,"cityname":"vvv"}]
Comments
Post a Comment