matteodem / meteor-easy-search

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

Pagination for Joined Collections #515

Closed Amritpd closed 7 years ago

Amritpd commented 8 years ago

I want to paginate my results that are from two collections. How exactly would I go about doing that?


    {{> EasySearch.Input indexes=indexes}} <!-- Search Bar -->
        <ul>
            {{#EasySearch.Each index=playerIndex}} 
                <li>{{first}} {{last}} </li>
            {{/EasySearch.Each}}
        </ul>
        <ul>
            {{#EasySearch.Each index=usersIndex }}  
                <li>{{username}}</li>
            {{/EasySearch.Each}}
        </ul>
matteodem commented 8 years ago

What's the exact use case of your app?

Amritpd commented 8 years ago

A user wants to add a player to a game. The player can be one that the user created and therefore a part of the Players collection (an object in the Players collection has attributes like playerId, firstName, and lastName, so the fields I specified for the playerIndex are just firstName and lastName). Or, the player can be another user, and for the usersIndex I specified the username for the searchable field. Hence, the user can add a player by typing their first/last name or by typing their username if they are an existing user. I know your docs explain custom pagination a bit:

{{> EasySearch.Pagination index=myIndex customRenderPagination="myPagination"}}
</template>

<template name="myPagination">
  <ul class="pagination">
    {{#each page}}

      <li class="page {{pageClasses this}}">
{{content}}
</li>
  
  {{/each}}
  </ul>
</template>

However, I don't know what the {{page}} or {{content}} helpers are doing. Is there any way to simply specify indexes=indexes in the call to EasySearch.Pagination?

Thanks a lot!

matteodem commented 7 years ago

Check the first recipe mentioned here