JQuery autocomplete problem
- by heffaklump
Im using JQuerys Autocomplete plugin, but it doesn't autocomplete upon entering anything.
Any ideas why it doesnt work? The basic example works, but not mine.
var ppl = {"ppl":[{"name":"peterpeter", "work":"student"},
{"name":"piotr","work":"student"}]};
var options = {
matchContains: true, // So we can search inside string too
minChars: 2, // this sets autocomplete to begin from X characters
dataType: 'json',
parse: function(data) {
var parsed = [];
data = data.ppl;
for (var i = 0; i < data.length; i++) {
parsed[parsed.length] = {
data: data[i], // the entire JSON entry
value: data[i].name, // the default display value
result: data[i].name // to populate the input element
};
}
return parsed;
},
// To format the data returned by the autocompleter for display
formatItem: function(item) {
return item.name;
}
};
$('#inputplace').autocomplete(ppl, options);
Ok. Updated:
<input type="text" id="inputplace" />
So, when entering for example "peter" in the input field. No autocomplete suggestions appear. It should give "peterpeter" but nothing happens.
And one more thing. Using this example works perfectly.
var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
$("#inputplace").autocomplete(data);