LeaVerou / awesomplete

Ultra lightweight, usable, beautiful autocomplete with zero dependencies.

Home Page:http://leaverou.github.io/awesomplete/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Suggestions with different label and value" - feature seems to have an issue

namelessbillionaire opened this issue · comments

var input = document.getElementById("myinputs");
new Awesomplete(input, {
list: [
{ label: "Belarus", value: "BY" },
{ label: "China", value: "CN" },
{ label: "United States", value: "US" }
]
});

I tried this code but what it does is not what is expected.
typing in US should display 'United States' but it displays 'belarUS'.

Screen Shot 2020-04-16 at 11 39 38

I've tried putting the javascript before and after the body but it still does not work.
I also checked it via Chrome's developer tools but there was no error returned.

Please help.

This ism expected behavior consistent with what the documentation says on https://leaverou.github.io/awesomplete/
// Show label but insert value into the input:
When Awesomplete searches, it searches and displays labels. If an option is selected, the text input is populated with the value.
For example, had you selected "Belaraus" from the suggestions, the input would have the value "BY" not "Belarus".

@bbenjamin I appreciate the prompt response and I apologize for misinterpreting the documentation.

Anyway, I'll go out on a limb here and ask since I guess you know this stuff well if you know of a way to accomplish what I, for the past few weeks, have been searching the internet for. It would really help me in my current project man. A little desperate over here.

Any help will do! Thank you and take care!

@namelessbillionaire Have you tried using a custom search function?