Meteor-Community-Packages / meteor-autocomplete

Client/server autocompletion designed for Meteor's collections and reactivity.
https://atmospherejs.com/mizzao/autocomplete
MIT License
350 stars 109 forks source link

Value for field #70

Closed mrn3 closed 9 years ago

mrn3 commented 9 years ago

I have autocomplete working well, but I can't get it to insert the value of the field. In other words, I have the autocomplete field on a form that populates values from the database, and I want the autocomplete field to have the value from the database.

I know this is bad syntax because I am putting handlebars within handlebars, but I am not sure how to do this:

{{> inputAutocomplete settings=settings id="openingHymn" name="openingHymn" value="{{openingHymn}}" class="form-control" placeholder="Opening Hymn"}}

Do I need to get inside your package and put the value inside your template? I am not sure how to accomplish this without getting inside your template.

Thanks.

mizzao commented 9 years ago

Just value=openingHymn should do it. No quotes, no handlebars.

mrn3 commented 9 years ago

Great - thanks for the quick response - that worked perfectly. Sorry for the lame question that was more of a handlebars question than one specific to your package!

mizzao commented 9 years ago

No problem. What if the service has more than one opening hymn, though? :)

mrn3 commented 9 years ago

Good question - I will cross that bridge when I get there. We usually don't have more than one opening hymn!

Along those lines, I am still having issues when I want people to look up the hymn based on number or name - it is working with the regex $or expression, but I would like it to populate the field with number - name, for example "324 - How Great Thou Art". Currently, it only puts in the number. Any advice?

Template.postEdit.helpers({ settings: function() { return { position: "bottom", limit: 5, rules: [ { collection: Hymns, field: "number", sort: 1, template: Template.hymnList, selector: function (match) { regex = new RegExp(match, 'i') return {$or: [{'name': regex}, {'number': regex}]} } } ] } } });

shrop commented 9 years ago

@mrn3 thanks for your example selector function. It helped me figure some things out on my autocomplete functionality!

mrn3 commented 9 years ago

You bet - no problem!