Gravatar for slangevin@coveo.com

Question by Simon, Dec 23, 2014 10:49 AM

Expanding the hierarchical facet by default.

Hi,

Using the JavaScript UI, I would like to expand a certain parent facet by default so that the child appears on page load until the user collapse it.

Using the $('.CoveoHierarchicalFacet').coveo('expandFacet'); jQuery call does not appear to work.

Cheers,

2 Replies
Gravatar for slangevin@coveo.com

Answer by Simon, Dec 24, 2014 2:49 PM

Expand facet didn't work because the facet has no subitems yet on "afterInitialiation", it is not until the search has run that there are subitems, changing to on deferredQuerySuccess seems to have worked.

Gravatar for vseguin@coveo.com

Answer by Vincent Séguin, Dec 23, 2014 11:16 AM

Hi Simon,

I'm wondering where did you put that script. You need to make sure it's in an 'afterInitialization' event of the JS UI, for instance Coveo.$('#search').on('afterInitialization', function() { Coveo.$('.CoveoHierarchicalFacet').coveo('expandFacet'); })

You could also add a breakpoint there and try to simply select $('.CoveoHierarchicalFacet') in the Chrome console to see if it actually returns you the facet.

Ask a question