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

React everytime a reactive variable changes (Components API) #30

Closed
MatthiasEckhart opened this issue Sep 1, 2014 · 4 comments
Closed
Labels

Comments

@MatthiasEckhart
Copy link

Hello,
is it possible to run a function (client-side) every time a user performs a search?

@matteodem
Copy link
Owner

Hello Matthias

As of now there's no documented way to do this. I'll most likely change the way of calling the API and this will be reflected in the documentation then.

Right now you can do it like this: https://github.com/matteodem/starthacking/blob/master/client/modules/searchbar/searchbar.js#L5

@matteodem matteodem reopened this Sep 1, 2014
@matteodem
Copy link
Owner

I'll keep this open until there's a "real API" for it.

@MatthiasEckhart
Copy link
Author

Hello,
thank you for your help! I have to update an instance, every time the search output changes. Also for "Loading…", "Search for players" and "No results found!". I already tried it with the solution you provided and with Meteor keyup events, but I didn't get the desired results, because the instance is in a stale state, until the next user input. Do you have a solution for this issue?

<template name="searchTpl">
    <div class="search-input">
        {{> esInput index="players" placeholder="Search..." }}
    </div>

    {{#ifEsInputIsEmpty index="players"}}
        <div>Search for players</div>
    {{/ifEsInputIsEmpty}}

    {{#ifEsIsSearching index="players"}}
        <div>Loading...</div>
    {{else}}
        <div class="results-wrapper">
            {{#esEach index="players"}}
                {{> player}}
            {{/esEach}}
        </div>
    {{/ifEsIsSearching}}

    {{#ifEsHasNoResults index="players"}}
        <div class="no-results">No results found!</div>
    {{/ifEsHasNoResults}}
</template>

Thanks in advance.

@matteodem matteodem changed the title Run a function every time a search is performed Implement Search Components Javascript API Sep 3, 2014
@matteodem matteodem changed the title Implement Search Components Javascript API React everytime a reactive variable changes (Components API) Sep 7, 2014
@matteodem
Copy link
Owner

hello there, this is how I implemented it: https://github.com/matteodem/meteor-easy-search#component-events.

I'll shortly add a list of possible "events" to react on. Please re-open if you have any other problems regarding this problem.

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

No branches or pull requests

2 participants