Gravatar for rbarbedo@nonlinear.ca

Question by robertobarbedo, Mar 18, 2015 1:54 PM

Javscript event on Standalone Search Box before search

Hi.

I am using a standalone search box with Coveo to Sitecore.

I would like to know if there is any js event fired before the component redirect to the search page.

this is my JS code so far:

Coveo.Rest.SearchEndpoint.endpoints["default"] = new Coveo.Rest.SearchEndpoint({
    restUri: getProductSearchData('coveo-rest')
});
$('#txtProductSearch').coveo('initSearchBox', '/url/of/search/page.html');

Thank you

1 Reply
Gravatar for slangevin@coveo.com

Answer by Simon, Mar 18, 2015 1:58 PM

Do you mean this?

https://developers.coveo.com/display/public/SC201503/Altering+Search+Results+Before+They+Are+Displayed+in+a+Search+Interface

Gravatar for rbarbedo@nonlinear.ca

Comment by robertobarbedo, Mar 18, 2015 2:01 PM

Hi, not, actually I am looking for a javascript event. I will add more details as well. thanks you

Gravatar for slangevin@coveo.com

Comment by Simon, Mar 18, 2015 7:17 PM

No there are no event before the redirect. You can bind your code to one of the events preceding the init of the search interface, but not the search box. What were you trying to accomplish this way? Maybe there is a workaround.

Gravatar for rbarbedo@nonlinear.ca

Comment by robertobarbedo, Mar 25, 2015 9:11 AM

Hi Simon. I am tryng to handle this event to change the redirect to the search page. I have a standalone search box and another box where the user can inform the price.

When the user type a query in the searchbox and hit enter, only the typed query is sent to the result page. Before redirecting to the result page I'd like to add the price info as well.

Gravatar for slangevin@coveo.com

Comment by Simon, Mar 25, 2015 10:49 AM

The standalone search box is not really a good idea for this. It is really simple and there are no events on which you can bind your code. I would instead use the real search box component.

Ask a question