I need your help. I'm trying to put an autocomplete on dynamically create text input but I have got some problem. I would like to use the JSON file because the ajax request took 1/2 sec and for my use it's too much.
Here is the code:
$(document).on('keydown.autocomplete',"[id$=_buy_mod]",function() {
$(this).autocomplete({
source: function(request,response) {
$.ajax({
ttpe: "GET",
url: "js/articoli.json",
data: {
term: request.term
},
dataType:'json',
dataFilter: function(data) {return data;},
success: function(data) {
response($.map(data,function(product) {
return {
label: product.label,
value:product.value
};
}))
},
})
},
minLength: 1,
select: function( event, ui ) {
var localid = $(this).attr('id');
var numerolocal = localid.match(/\d+/);
console.log(numerolocal);
$(this).val(ui.item.label);
$("[id$="+numerolocal+"_buy_id_mod]").val(ui.item.value)
return false;
}
});
Actually timing is good but autocomplete is not filtering data and it show me all possible words.
Here is the json file
[{"value": "1","label": "Panasonic Lumix L1"},
{"value": "10","label": "Sigma 17-50mm f 2.8 OS Canon"},
{"value": "11","label": "Canon 1000D"},
{"value": "1100D","label": "Canon 1100D"}
-------
How can I solve?