Code Monkey home page Code Monkey logo

Comments (16)

matteodem avatar matteodem commented on May 18, 2024

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

from meteor-easy-search.

wbashir avatar wbashir commented on May 18, 2024

Yes that is correct. Thanks

from meteor-easy-search.

matteodem avatar matteodem commented on May 18, 2024

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

from meteor-easy-search.

matteodem avatar matteodem commented on May 18, 2024

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

from meteor-easy-search.

wbashir avatar wbashir commented on May 18, 2024

@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 ?

from meteor-easy-search.

matteodem avatar matteodem commented on May 18, 2024

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.

from meteor-easy-search.

Shelagh-Lewins avatar Shelagh-Lewins commented on May 18, 2024

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.

from meteor-easy-search.

dylanmcgowan avatar dylanmcgowan commented on May 18, 2024

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.

from meteor-easy-search.

matteodem avatar matteodem commented on May 18, 2024

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.

from meteor-easy-search.

matteodem avatar matteodem commented on May 18, 2024

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

from meteor-easy-search.

dylanmcgowan avatar dylanmcgowan commented on May 18, 2024

How do you do it?
like

EasySearch.Components.clear(index, id);

or

EasySearch.Cursor.emptyCursor 

?

from meteor-easy-search.

matteodem avatar matteodem commented on May 18, 2024

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.

from meteor-easy-search.

dylanmcgowan avatar dylanmcgowan commented on May 18, 2024

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

from meteor-easy-search.

Shelagh-Lewins avatar Shelagh-Lewins commented on May 18, 2024

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("")

from meteor-easy-search.

Shelagh-Lewins avatar Shelagh-Lewins commented on May 18, 2024

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.

from meteor-easy-search.

meecect avatar meecect commented on May 18, 2024

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}}

from meteor-easy-search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.