When using autocomplete feature, it retrieves data while i type. This is ok.
But when i select a matching word , the text field is populated with the number coresponding with the word found in 'matches' array and not with the selected word as it should be.
If i change line:
li.autocompleteValue = key;
with:
li.autocompleteValue = matches[key];
it seems to work fine.
Is this a bug, or am I missing something?
Original Code (in autocomplete.js):
.......
var ul = document.createElement('ul');
var ac = this;
for (key in matches) {
var li = document.createElement('li');
$(li)
.html('
')
.mousedown(function () { ac.select(this); })
.mouseover(function () { ac.highlight(this); })
.mouseout(function () { ac.unhighlight(this); });
li.autocompleteValue = key; //------------------------ here is the line (212)---------------
$(ul).append(li);
}
.......
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | example.jpg | 125.15 KB | coolboygfx |
Comments
Comment #1
coolboygfx commentedComment #2
rfayI actually have had to copy and enhance autocomplete.js to use it for my own purposes before. On the other hand there are lots of successful examples of its use.
I'll see if I can take a look at this. It's been a while.
Comment #3
rfayComment #4
coolboygfx commentedOk I've found that I've made a mistake in my test module.
My previous module function for construct autocomplete result was:
In fact this function should be:
Conclusion: autocomplete.js display in drop down values from the returned array, but when selecting one it selects the key
for that value.
But, i do not understant the logic behind duplicating array values to array keys while we are only interested in values.
Anyway I'll do that.
Comment #5
coolboygfx commentedI close this issue.