diff --git a/README.md b/README.md index 203dfeb..fd55939 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/autocomplete-client.coffee b/autocomplete-client.coffee index 210c4dd..d602f3b 100644 --- a/autocomplete-client.coffee +++ b/autocomplete-client.coffee @@ -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 diff --git a/inputs.html b/inputs.html index c5ed6e1..63c11ba 100644 --- a/inputs.html +++ b/inputs.html @@ -28,7 +28,7 @@ {{> noMatchTemplate }} {{/unless}} {{else}} - loading... + {{> loadingTemplate }} {{/if}} {{/if}} @@ -37,3 +37,7 @@ + + \ No newline at end of file diff --git a/templates.coffee b/templates.coffee index cd56d8b..9a7a86d 100644 --- a/templates.coffee +++ b/templates.coffee @@ -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