Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to search not only by label? I want to search also to value or other fields #17220

Open
kritsky opened this issue May 4, 2020 · 1 comment

Comments

@kritsky
Copy link

kritsky commented May 4, 2020

new Awesomplete(input, {
list: [
{ label: "Belarus", value: "BY" },
{ label: "China", value: "CN" },
{ label: "United States", value: "US" }
]
});

When I type CN there will be result China

@bbenjamin
Copy link
Collaborator

You can do this by customizing the filter. An example in this is in the "Extend" section on https://leaverou.github.io/awesomplete/#extensibility - it is the first item in the table.

The "text" function arg is typically treated as a string with the suggestion label, but it actually an object that provides both the label and value in text.label and text.value. Update the filter function to check both text.label and text.value instead of just text and you'll get the functionality you're looking for!

If this answers your question successfully, please close the issue or I'll close after a week of inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants