Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't seem to get the autocomplete to work #36

Closed
queso opened this issue May 2, 2014 · 3 comments
Closed

I can't seem to get the autocomplete to work #36

queso opened this issue May 2, 2014 · 3 comments

Comments

@queso
Copy link

queso commented May 2, 2014

So I've created an input:

        <h3>Cause</h3>
        <div class="row">
          <div class="form-group col-md-6">
            {{> inputAutocomplete settings=autocompleteSettings id="cause" name="cause" class="form-control" placeholder="Cause name..."}}
          </div>
        </div>

And I added some settings via the template:

Template.createPayment.helpers
  autocompleteSettings: ->
    position: 'bottom'
    limit: 10
    rules: [
        {
          collection: Cause,
          field: "name",
          matchAll: true,
          subscription: 'causes',
          template: Template.cause
        }
      ]

And then I setup a subscription for the causes:

Meteor.publish 'causes', (selector, options) ->
  console.log 'Subscribing to causes'
  collection = Cause

  sub = this

  # guard against client-side DOS: hard limit to 50
  options.limit = Math.min(50, Math.abs(options.limit)) if options.limit

  # Push this into our own collection on the client so they don't interfere with other publications of the named collection.
  console.log("SELECTOR #{selector}")
  handle = collection.find(selector, options).observeChanges
    added: (id, fields) ->
      sub.added("autocompleteRecords", id, fields)
    changed: (id, fields) ->
      sub.changed("autocompleteRecords", id, fields)
    removed: (id) ->
      sub.removed("autocompleteRecords", id)

  sub.ready()
  sub.onStop -> handle.stop()

I never see the console.log output from the subscription, so I am thinking I did something wrong there? I see the autocomplete come up after I type 2 letters I see the 'no matches' message, so I know some of it is working.

@mizzao
Copy link
Collaborator

mizzao commented May 2, 2014

For server-side autocomplete you need to specify the collection name as a string, i.e. "Cause".

Can you let me know if that works?

@queso
Copy link
Author

queso commented May 2, 2014

BOOM

That was it! Thanks for your help :)

@mizzao
Copy link
Collaborator

mizzao commented May 2, 2014

No problem, I can provide a more precise error message in case others run into this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants