Reputation: 5233
My setup using typeahead-js is below. It's working very well locally with no problems. However, when I deploy to meteor, it's no longer working in that the datums are the same but the typeahead is not happening.
On Meteor.client:
Template.searchProfiles.rendered = function() {
$('input#query').typeahead({
name:'searchProfiles',
local:searchProfilesDatums(),
});
}
var searchProfilesDatums = function() {
var datums = [];
Profiles.find().forEach(function(profile) {
tokens = profile.name.split(" ");
datums.push({value:profile.name, nameRoute:profile.nameRoute, tokens:tokens});
});
return datums;
}
Upvotes: 1
Views: 486
Reputation: 8865
When you provide the "name" attribute to a typeahead datum - it caches the datum, and re-initialising any typeahead with another datum with the same name will re-use the datum - including local values.
If you're running remotely - the first datum may be initialised at a time when there's no data in the collection (eg waiting for the subscription), and subsequent datum's are ignored in favour of the cached one.
Possible solutions:
I'm currently using a modified branch which allows for computed values, but I have some of my own twists on it.
Upvotes: 1