Reputation: 7832
I've added atmospherejs.com/package/typeahead to a meteor project and it's working fine. It's returning a string but can I change typeahead to return an object and have the template render the object accordingly? I need the _id in addition to the name from the participant I'm adding to a mongodb-collection.
js-file:
Template.raceAddParticipant.acparticipants = function () {
return Participants.find().fetch().map(function (post) { return post.name; });
};
html-file:
<input class="form-control typeahead" autocomplete="off" spellcheck="off" data-source="acparticipants" name="name" type="text" value="" placeholder="Participant" />
regards Claus
Upvotes: 0
Views: 260
Reputation: 36930
Typeahead is not designed for Meteor and you will need to do a lot of wrangling to work with the strings it returns.
One solution is to use something like https://github.com/mizzao/meteor-autocomplete, which works of Meteor Collections instead of arrays, is reactive, and supports rendering using Meteor templates with proper data contexts (i.e. _id
and all other fields). It's basically like typeahead, but designed around Meteor.
Upvotes: 1