Gravatar for andrew.harbert@nttdata.com

Question by adharbert, Nov 26, 2014 1:56 PM

Edit facets through JavaScript

Hi, I'm trying to edit the facets on a search page during the page load. Due to how facets work, we had to group items into one facet type. So we need to programmatically go through them and change the text.

I am trying to find a way to grab them but any event I add seem to fire off before the facets are rendered. Would anyone know how to either override this or fire an event off after the facets load?

Thanks!

2 Replies
Gravatar for cbolduc@coveo.com

Answer by Carl Bolduc, Nov 26, 2014 2:08 PM

Have a look at the source of our technical blog search page, here is the relevant code for your needs:

var myValueCaption = {  "Developers.coveo.com.public" : "Developers",
                        "answers" : "Answers",
                        "BlogTech" : "Technical Blog"};
$("#search").coveo("init", {
    Facet : {
        valueCaption : myValueCaption
    }
})     
Gravatar for olamothe@coveo.com

Comment by olamothe, Nov 26, 2014 2:20 PM

Link to the docs regarding this option : https://developers.coveo.com/display/JsSearch/Facet+Component#FacetComponent-valueCaption

Gravatar for vseguin@coveo.com

Answer by Vincent Séguin, Nov 26, 2014 2:07 PM

Hi Andrew,

If you go there : https://developers.coveo.com/display/JsSearch/Events The deferredQuerySuccess event gets fired when everything is rendered, you could try it.

Gravatar for andrew.harbert@nttdata.com

Comment by adharbert, Nov 26, 2014 2:30 PM

so I tried using afterComponentsInitialization and that fires off before the facets load. so not really sure what else to use.

Ask a question