Skip to content

Instantly share code, notes, and snippets.

@booyaa
Last active December 21, 2015 03:29
Show Gist options
  • Save booyaa/6243041 to your computer and use it in GitHub Desktop.
Save booyaa/6243041 to your computer and use it in GitHub Desktop.
server/publish.js
Meteor.publish('typeahead', function() {
var typeAheadList = Lists.findOne({name: 'Typeahead'});
console.log('typeahead %s', typeAheadList._id);
var words = Todos.find({list_id : typeAheadList._id});
console.log('doc count %d', words.count());
words.forEach(function(item) {
console.log('%s ', item.text);
});
return words;
});
// client side code
Meteor.subscribe('typeahead');
TypeAhead = new Meteor.Collection("typeahead");
// helper that i add to a bootstrap input with typeahead enabled
Template.todos.typeahead = function () {
var typeAheadList = TypeAhead.find();
console.log('collar felt %s', JSON.stringify(typeAheadList));
return JSON.stringify(typeAheadList);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment