Gravatar for

Question by Simon, May 21, 2014 9:33 AM

Event triggered when the facet's HTML is built?

newResultsDisplayed is used when the results are returned and HTML is built on the JS side. Is there a similar event for when the facet's HTML is built? The facet’s HTML is built latter and I am not able to use newResultsDisplayed event for this purpose.

Can anyone give me a sample of code which I can use to bind to this event. What I am looking for is an event fired when the Facet HTML is completed in the DOM after the request comes back from Coveo.


2 Replies
Gravatar for

Answer by Alexandre Paré, May 21, 2014 9:41 AM

The rendering of facet are trigger by an event call deferredQuerySuccess.

Try this :

$("#search").on('afterInitialization', function(){ $("#search").on('deferredQuerySuccess' function(){ // your facet will be updated }) })

Gravatar for

Comment by tauqir-ntt, May 21, 2014 10:02 AM

This worked for me. It has to be nested as show above. If I only use deferredQuerySuccess then it doesn't work.

Gravatar for

Comment by Alexandre Paré, May 21, 2014 10:06 AM

The afterInitialization event allowed you to be the last one to catch the event deferredQuerySuccess otherwise you will catch this event before Facets.

Gravatar for

Answer by Martin Laporte, May 21, 2014 9:38 AM

The event you are looking for is deferredQuerySuccess. When new results come in, the querySuccess event is first raised to update the result list and a few other things. Other UI updates are done in a separate step to allow the browser to display the results faster, and facets are updated at this moment. This second phase is done through deferredQuerySuccess.

Ask a question