Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ Template.foo.helpers({
- `token`: (optional) What character should trigger this rule. Leave blank for whole-field behavior (see below).
- `collection`: What collection should be used to match for this rule. Must be a `Mongo.Collection` for client-side collections, or a string for remote collections (available in `global` on the server.)
- `subscription`: A custom subscription for server-side search; see below.
- `subscriptionParams` - additional information required by the publication function, i.e. providing additional data for accessing external APIs (like token, etc)
- `template`: The template that should be used to render each list item.
- `filter`: (optional) An object that will be merged with the autocomplete selector to limit the results to more specific documents in the collection.
- `sort`: (default `false`) Whether to sort the results before applying the limit. For good performance on large collections, this should be turned on only for server-side searches where an index can be used.
- `noMatchTemplate`: (optional) A template to display when nothing matches. This template can use the [reactive functions on the AutoComplete object](autocomplete-client.coffee) to display a specific message, or be [assigned mouse/keyboard events](http://docs.meteor.com/#eventmaps) for user interaction.
- `loadingTemplate`: (optional) A customized template to be displayed when waiting for server results

Default matcher arguments: the default behavior is to create a regex against the field to be matched, which will be constructed using the arguments below.

Expand Down
3 changes: 2 additions & 1 deletion autocomplete-client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ class @AutoComplete
# console.debug 'Subscribing to <%s> in <%s>.<%s>', filter, rule.collection, rule.field
@setLoaded(false)
subName = rule.subscription || "autocomplete-recordset"
subscriptionParams = rule.subscriptionParams || rule.collection
@sub = Meteor.subscribe(subName,
selector, options, rule.collection, => @setLoaded(true))
selector, options, subscriptionParams, => @setLoaded(true))

teardown: ->
# Stop the reactive computation we started for this autocomplete instance
Expand Down
6 changes: 5 additions & 1 deletion inputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{{> noMatchTemplate }}
{{/unless}}
{{else}}
<i>loading...</i>
{{> loadingTemplate }}
{{/if}}
</div>
{{/if}}
Expand All @@ -37,3 +37,7 @@
<template name="_noMatch">
(<i>no matches</i>)
</template>

<template name="_loading">
<i>loading...</i>
</template>
1 change: 1 addition & 0 deletions templates.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ Template._autocompleteContainer.events
Template._autocompleteContainer.helpers
empty: -> @filteredList().count() is 0
noMatchTemplate: -> @matchedRule().noMatchTemplate || Template._noMatch
loadingTemplate: -> @matchedRule().loadingTemplate || Template._loading