forked from Meteor-Community-Packages/meteor-autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.js
40 lines (37 loc) · 1.51 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// client-only collection to demo interoperability with server-side one
Fruits = new Mongo.Collection(null);
['Apple', 'Banana', 'Cherry', 'Date', 'Fig', 'Lemon', 'Melon', 'Prune', 'Raspberry', 'Strawberry', 'Blueberry', 'Blackberry', 'Boysenberry', 'Licorice', 'Watermelon', 'Tomato', 'Jackfruit', 'Kiwi', 'Lime', 'Clementine', 'Tangerine', 'Orange', 'Grape'].forEach(function (fruit) {
Fruits.insert({type: fruit})
});
Template.pubsub.helpers({
settings: function() {
return {
position: Session.get("position"),
limit: 30, // more than 20, to emphasize matches outside strings *starting* with the filter
rules: [
{
token: '@',
// string means a server-side collection; otherwise, assume a client-side collection
collection: 'BigCollection',
field: 'name',
options: '', // Use case-sensitive match to take advantage of server index.
template: Template.serverCollectionPill,
noMatchTemplate: Template.serverNoMatch
},
{
token: '!',
collection: Fruits, // Mongo.Collection object means client-side collection
field: 'type',
// set to true to search anywhere in the field, which cannot use an index.
matchAll: true, // 'ba' will match 'bar' and 'baz' first, then 'abacus'
template: Template.clientCollectionPill
}
]
}
}
});
Template.pubsub.events({
"autocompleteselect textarea": function(e, t, doc) {
console.log("selected ", doc);
}
});