Gravatar for jschjolberg@awareweb.com

Question by jschjolberg, May 14, 2014 3:49 PM

Clear All Filters - JavaScript Search Framework

Hi - is there a way to call the method that clears all filters directly from JavaScript? I see that a x-box appears that allows you to do this when you select filters. Can I call the method that that box is using? Thanks!

2 Replies
Gravatar for olamothe@coveo.com

Answer by olamothe, May 14, 2014 3:53 PM

Yes. The "reset" method is public on the facet

Documentation

You can do something like this :

$('#myFacet').coveo('reset')
$("#mySearch").coveo("executeQuery")

If you wish to reset all Facet at once , call this instead :

$('.CoveoFacet').coveo('reset')
$("#mySearch").coveo("executeQuery")
Gravatar for jschjolberg@awareweb.com

Comment by jschjolberg, May 14, 2014 5:03 PM

Thank you - that worked great. Is there documentation somewhere that lists all of the different coveo methods that are available to call?

Gravatar for olamothe@coveo.com

Comment by olamothe, May 14, 2014 5:07 PM

Yep, every "Components" should have a section called Public methods. Each of these are public, and thus, callable using the JQuery extension.

https://developers.coveo.com/display/JsSearch/Components

In the side menu on the left, you should see a drop down menu under component that list them all.

Also, don't forget to "accept" the answer, this should help other people that have the same problem finding a solution more easily :)

Gravatar for abuteau@coveo.com

Answer by abuteau, Jun 27, 2014 11:09 AM

Disclaimer : I'm a complete noob in JQuery.

Suppose I want to apply the clear all filters to a span/link on click.

This is my span:

<span class="pl-rightarrow">&nbsp;&nbsp; Clear All</span>

This is my function:

 $(document).ready(function () {
     $('.pl-rightarrow').click(function () {
         Coveo.$('.CoveoFacet').coveo('reset');
         Coveo.$("#search").coveo("executeQuery");
     });
 });

Not working though. How could I achieve that ?

Thanks,

Gravatar for abuteau@coveo.com

Comment by abuteau, Jun 27, 2014 1:00 PM

Nevermind the "Coveo." was missing before the $ Thanks.

Ask a question