sergeyt / meteor-typeahead

Autocomplete package for meteor powered by twitter typeahead.js
https://atmospherejs.com/sergeyt/typeahead
MIT License
146 stars 82 forks source link

Use different field for storing value #98

Open mortomanos opened 9 years ago

mortomanos commented 9 years ago

I would like to achieve the following:

my function for the dataset returns an object array in the form of

return Users.find().fetch().map( function (it) {
      return {
        id: it._id,
        value: it.lastname + ", " + it.firstname,
        abbr: it.abbr
      }
    });

During typeahead, the dropdown should fill in values from the value field. After selecting the correct result, the value stored in the input field should be the abbr field.

I tested around with supplying multiple datasets, using displayKey and valueKey but that didn't work, because there is no way to have a computed value like in the example above, and also the search uses valueKey.

sergeyt commented 9 years ago

@mortomanos you could try to use data-select attribute to specify event handler where selected suggestion will be your object.