matteodem / meteor-easy-search

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

Is it possible to use search input and results in separate templates? #430

Closed zhukovsp closed 8 years ago

zhukovsp commented 8 years ago

Hello Matteo! I tried the package - it works great! Thank you! Sorry for stupid question I’m newbie in Meteor. I would be very appreciate if you give me a little advice or right direction with it...

My page has search area in navigation bar template "(navbar") and content in another template ("main"). Is it possible to show search results in “main" template when using search input in “navbar" or to ties templates somehow?

Something like that:

<template name="navbar">
{{> EasySearch.Input index=playersIndex }}
</template>
<template name="main">
    <ul>
        {{#EasySearch.Each index=playersIndex }}
            <li>Name of the player: {{name}}</li>
        {{/EasySearch.Each}}
    </ul>
</template>

// On Client and Server
let Players = new Mongo.Collection('players'),
  PlayersIndex = new EasySearch.Index({
    collection: Players,
    fields: ['name'],
    engine: new EasySearch.Minimongo()
  });

// On Client
Template.main.helpers({
  playersIndex: () => PlayersIndex
});
matteodem commented 8 years ago

Yes it is, simply use the components and write everything as you would without EasySearch and then add the EasySearch.Input where you would want the search input to be.

zhukovsp commented 8 years ago

Thank you!