matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
437 stars 68 forks source link

Customize Autosuggest template #512

Closed RafOXxxx closed 7 years ago

RafOXxxx commented 8 years ago

Hi there,

could someone please give an example how to create a customized Autosuggest template. To me it is not clear how to achieve that. So far I copied the original template, renamed it and added the "suggestionTemplate" parameter and the name of the new template to my collection index like so:

CollectionIndex = new EasySearch.Index({
        collection: this.Collection,
        fields: ['name', 'city'],
        suggestionTemplate: 'MyAutogguestTemp',
        engine: new EasySearch.Minimongo({
            aggregation: '$or',
        }),
    });

<template name="MyAutogguestTemp">
  <div>
    <span class="autosuggest-title"><span class="name"><p>This is a test</p>{{label}}</span></span>
  </div>
</template>

I expected to see "This is a test" in front of every suggestion

matteodem commented 8 years ago

You need to pass the argument to the blaze template inclusion:

<div class="my-autosuggest">
  {{> EasySearch.Autosuggest index=myIndex suggestionTemplate="mySuggestions"}}
</div>

I'll reopen if the problem keeps persisting

RafOXxxx commented 8 years ago

Thanks for your help but that is exactly what I tried in the first place. All the other parameters work but it seems like it won't take the "suggestionTemplate" parameter. Does the template has to be in a certain place in the file structure?

2016-06-29 17:18 GMT+02:00 Matteo De Micheli notifications@github.com:

You need to pass the argument to the blaze template inclusion:

{{> EasySearch.Autosuggest index=myIndex suggestionTemplate="mySuggestions"}}

I'll reopen if the problem keeps persisting

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/matteodem/meteor-easy-search/issues/512#issuecomment-229389691, or mute the thread https://github.com/notifications/unsubscribe/AFtL05b4dGUd37HCo3i28CSgSpmaEzEcks5qQozHgaJpZM4I-ZGq .

matteodem commented 8 years ago

Please try renderSuggestion, I think the docs might be wrong.