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

How to define more that two key:value pairs? #57

Open
oshihirii opened this issue Jun 4, 2017 · 0 comments
Open

How to define more that two key:value pairs? #57

oshihirii opened this issue Jun 4, 2017 · 0 comments

Comments

@oshihirii
Copy link

oshihirii commented Jun 4, 2017

Hello,

I am just wondering what is the best way to utilise more than two key:value pairs?

Here is a jsFIddle test that seems to be working, with:

horsey(document.querySelector('input'), {
  source: [{ list: [
    { value: 'banana', text: 'Bananas from Amazon', description: '[ bananas are yellow ]'},
    { value: 'apple', text: 'Red apples from New Zealand', description: '[ apples are red ]' },
    { value: 'orange', text: 'Oranges from Moscow', description: '[ oranges are orange ]'},
    { value: 'lemon', text: 'Juicy lemons from Amalfitan Coast', description: '[ lemons are green ]'}
  ]}],
  getText: 'text',
  getValue: 'value',
  getValue: 'description',
  renderItem: function (li, suggestion) {
    var image = "<img class=\"autofruit\" src=\"" + fruits[ suggestion.value] + "\">";
    li.innerHTML = image + suggestion.text + " " + "<div class=\"second\">" + suggestion.description + "</div>";
  }
});

As you can see, getValue is used twice, which is probably not how it was intended to be used?

Matches don't occur as expected on description, however, if it is not called via getValue (eg searches for are will only return one suggestion).

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

1 participant