Gravatar for

Question by jpdery, May 28, 2014 11:10 AM

Cannot initialize facet value: Cannot read property 'select' of undefined

Had this issue when I was trying to initialize a facet:

Uncaugth TypeError: Cannot read property 'select' of undefined

The code used was:

$('.CoveoFacet[data-field="@scope"]').coveo('selectValue', 'News')
Gravatar for

Comment by Martin Laporte, May 28, 2014 11:12 AM

Can you provide a callstack?

1 Reply
Gravatar for

Answer by jpdery, May 28, 2014 11:12 AM

I was suggested to use ensureDom(), which fixed the issue:

var facet = $('.CoveoFacet[data-field="@scope"]');
facet.coveo('selectValue', 'News');
Gravatar for

Comment by Alexandre Paré, May 28, 2014 11:14 AM

The facet is not initialize until it first become active. $('#MyFacet').coveo('ensureDom') initialize it.

I also recommend to use id instead of attribute selector.

<div id="MyFacet" class="CoveoFacet" data-field="@scope"></div>

$('#MyFacet').coveo('selectValue', "News")

Gravatar for

Comment by olamothe, May 28, 2014 11:22 AM

"The facet is not initialized until it first become active"

Active means the tab in which the facet is active is selected for the first time.

And that's a bug. The selectValue method should already take care of calling ensureDom(). Fixing it as we speak.

Gravatar for

Comment by jpdery, May 28, 2014 5:00 PM

@apare: understood about using ID but not applicable in my case where I am using Coveo for Sitecore which is rendering the markup of the facets without rendering an ID.

Ask a question