Gravatar for hernandez@rdacorp.com

Question by benaldo, Dec 5, 2016 8:44 AM

Global standalone search box not populating query value

Hi,

I'm working on a project that is upgrading from coveo 3.0 to coveo 4.0(450). We have a custom global search box in the header, that is working correctly with it's omnibox.

However, when the user is redirected to the search page, the standalone box does not prefill the query value, and the search term is ignored. I can see the q? value being passed in the url string correctly, so we must have an issue on the search page. We are using a custom search sublayout, and connecting the global search box to this layout as follows:

Coveo.$(function() {
    var searchOptions = <%= Model.GetJavaScriptInitializationOptions() %>;
    searchOptions.externalComponents= [Coveo.$(".CoveoSearchbox")];
    CoveoForSitecore.componentsOptions = Coveo.$.extend({}, CoveoForSitecore.componentsOptions, searchOptions);
})

and then :

Coveo.$('#search').coveoForSitecore('init', CoveoForSitecore.componentsOptions);

Our search div has id search, and the global searchbox is tagged with the class CoveoSearchbox. I've confirmed that the componentsOptions are being set correctly as well.

I've tried loading the components options on the searchbox control, using the same IsOnSearchPage function, but the results have been the same.

Do you have any other suggestions on what I could try?

Thanks!

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Dec 5, 2016 9:20 AM

Hi,

I have heard that since the September 2016 release of Coveo for Sitecore 4.0, external components array needs to contain DOM elements instead of jQuery elements. This is a regression from the previous releases and will be supported again in the upcoming January 2017 release of Coveo for Sitecore 4.0.

In the meantime, you can workaround the issue using:

searchOptions.externalComponents = [document.getElementById("<%= Model.SearchboxId %>")];
Gravatar for hernandez@rdacorp.com

Comment by benaldo, Dec 5, 2016 9:40 AM

Thank you, that did it!

Ask a question