Gravatar for

Question by Pedro Graca, Oct 28, 2016 7:25 AM

Javascript Search Framework - Uncaught TypeError: $(...).coveo is not a function


I am trying to determine the state of the current query but without success (using coveo for sitecore).

Through the console I am inputting the following:

$("#Top4").coveo('state', 'q');

or even if I try the following:

$("#Top4").coveo('state', { q: 'new query', sort: 'relevancy' });

I get the following error

Uncaught TypeError: $(...).coveo is not a function
Gravatar for

Comment by Simon, Oct 28, 2016 8:45 AM

Is this is a Coveo for Sitecore solution?

Gravatar for

Comment by Pedro Graca, Oct 31, 2016 5:15 AM

Hi Simon,

Yes, it's a coveo for sitecore solution.

Thank you

2 Replies
Gravatar for

Answer by Pedro Graca, Nov 1, 2016 7:40 AM

Hi flguillemette ,

It turns out I had a second jquery declaration as you suggested and by removing it seemed to have fixed the issue.

Thanks everyone for your help.

Gravatar for

Answer by Jean-François L'Heureux, Oct 28, 2016 9:35 AM

Hi Pedro,

The .coveo jQuery plugin is added in the page by the "Coveo Search Resources" Sitecore component. you must ensure your JavaScript code is declared below its inclusion in the final page.

One reason it could not be loaded is the use of the "Coveo Search Box Resources" component. This one includes only minimal code to enable the search box to redirect to the search page without loading the whole framework.

One thing to make sure is also to use Coveo.$(...) to use jQuery with Coveo components. the Coveo JavaScript Search Framework embeds its own version of jQuery and registers its plugin only in that version. Using Coveo.$ also ensures your code won't conflict with the PrototypeJS library when running in the Experience Editor context.

The correct syntax to read the basic query state is:

var q = Coveo.$('#ID of the element with the CoveoState CSS class').coveo('state', 'q');

I hope this helps


Gravatar for

Comment by Pedro Graca, Oct 31, 2016 5:35 AM

Hi Jeff,

I can confirm that the "Coveo Search Resources" Sitecore component is being used and place before the "Coveo Search" component. And even tho the js is being declared at the end of the latter I am still getting the same outcome.

Thank you

Gravatar for

Comment by François Lachance-Guillemette, Oct 31, 2016 9:06 AM

What Coveo for Sitecore version are you using? (with the build number)

Are you including a second version of jQuery in your page?


Ask a question