Hi,
I have problem in adding autocomplete plugin to multiple text inputs in loop (no errors are returned).
// get text inputs to attach autocomplete
var locinputs = $('#localizations').find('input:text');
// iterate over elements and add autocomplete plugin
for (var i = 0; i < locinputs.length; i++) {
// asp.mvc array with special characters replacing
var locNameField = locinputs[i].name.replace('[', '\\\\[');
locNameField = locNameField.replace(']', '\\\\]');
locNameField = locNameField.replace('.', '\\\\.');
$('input#' + locNameField).autocomplete('<%=Url.Action("GetCity", "Localization") %>', {
extraParams: {
provinceId: function () { return 21; }
},
dataType: 'json',
parse: function (data) {
var rows = new Array();
for (var i = 0; i < data.length; i++) {
rows[i] = { data: data[i], value: data[i].PlaceId, result: data[i].Name };
}
return rows;
},
formatItem: function (row, i, n) {
return row.Name;
},
width: 300,
mustMatch: true,
multiple: true
});
}
There is no error on loading, I tried to debug using Firebug, elements are accessible by jquery selector