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

Clear search results #29

Closed
wbashir opened this issue Aug 30, 2014 · 16 comments
Closed

Clear search results #29

wbashir opened this issue Aug 30, 2014 · 16 comments
Labels

Comments

@wbashir
Copy link

wbashir commented Aug 30, 2014

I am not sure but is there an underlying function within the source code to explicitly reset the search input esInput and the search results. Users of my application have found the search results stale when they browse away from a route and I would like to reset it back or I should say run a clear, if that is possible ?

@matteodem
Copy link
Owner

Just for clarification, you want to have the search results be cleared after navigating away to another page where the search is not displayed anymore, right?

I'll be sure to add this functionality through the API

@wbashir
Copy link
Author

wbashir commented Sep 1, 2014

Yes that is correct. Thanks

@matteodem
Copy link
Owner

You can now clear the search like following:

// index and id (is not required) are both blaze parameters:
// for example https://github.com/matteodem/meteor-easy-search#eseach
EasySearch.Components.clear(index, id);

Remember that the input might still have its value, this is not taken care of since you don't have to use the esInput (in theory). Feel free to re-open if there's anything missing regarding this ticket

@matteodem
Copy link
Owner

Also I have not documented this since I'll be re-working most of the Components to make a proper faceted search possible, see #21

@wbashir
Copy link
Author

wbashir commented Nov 29, 2014

@matteodem you mentioned not documenting this yet, I am kind of confused on how or where exactly I should be calling clear. Is there a handler that would be appropriate for this ?

@matteodem
Copy link
Owner

yeah, it's with the components API:
https://github.com/matteodem/meteor-easy-search/wiki/Component-API

It would be instead of "on" or "get" just "clear" without any parameters on the instance. I forgot to document that, I'll add that soonish.

matteodem pushed a commit that referenced this issue Dec 18, 2014
Changed "Lanyon" for "Hyde" in the features paragraph
@Shelagh-Lewins
Copy link

I can't get this working, EasySearch.Components doesn't seem to exist and I don't know what "index" or "id" should be? It's really important to automatically close the results list and clear the box when the user selects a result. I can't find any reference to 'clear' in the docs.

@dylanmcgowan
Copy link

I'm also wondering how to do this. Looking at the EasySearch object there is a EasySearch.Cursor.emptyCursor object but that is the closest thing i can find. How do you 'clear' the results with the new version?? thanks.

@matteodem
Copy link
Owner

I think this got forgotten with v2, it might make most sense to always reset "search results" as soon as the user navigates away. I'll implement it that way for now.

@matteodem
Copy link
Owner

Should have that behaviour now in latest version, please check it out.

@dylanmcgowan
Copy link

How do you do it?
like

EasySearch.Components.clear(index, id);

or

EasySearch.Cursor.emptyCursor 

?

@matteodem
Copy link
Owner

Do you want an explicit clear method? I did not add it but one way would be to use component methods to search for an empty string.

@dylanmcgowan
Copy link

Oh thats kind of genius haha, a dedicated method would be nice, but the empty string does the trick for now.

@Shelagh-Lewins
Copy link

I tried this:

 patternsIndex.search("");

but the search results stayed on screen. What am I doing wrong?

Edit: I got it, I think. This works:

patternsIndex.getComponentMethods().search("")

@Shelagh-Lewins
Copy link

Note: I want to hide the list if the user presses 'Esc' or clicks outside the list, so they don't have to go into the input and delete the search term to hide the search list. So that's a use case for manually clearing the list. I haven't tried it yet but I expect that your suggestion of searching for empty string will work for this.

@meecect
Copy link

meecect commented Mar 24, 2020

I can't get this to work.

I tried:

    ContentSearchIndex.getComponentMethods().reset();

and

    ContentSearchIndex.getComponentMethods().search("");

when I clear the search this way I just get all results, even though my search input component has noDocumentsOnEmpty=true:

    {{> EasySearch.Input indexes=searchIndexes charLimit=2 noDocumentsOnEmpty=true attributes=searchBoxAttributes}}

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

5 participants