JQuery autocomplete problem
Posted
by heffaklump
on Stack Overflow
See other posts from Stack Overflow
or by heffaklump
Published on 2010-05-19T11:11:11Z
Indexed on
2010/05/19
13:20 UTC
Read the original article
Hit count: 249
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);
© Stack Overflow or respective owner