Gravatar for ravigupta020287@gmail.com

Question by Ravi, Nov 16, 2016 4:19 AM

Need Latest Search Query text as the Title of the search page

I have requirement where i need Page Tilte as the Search term of the Search page. I tried using $("#search").coveo('state', 'q'); which is working fine on keypress on search box and also in double click of the search button. But on single click of the search button in search box the value is not getting updated in $("#search").coveo('state', 'q');.

Is there any other way to achieve this?

Thanks! Ravi

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Nov 16, 2016 5:03 AM

If I had to guess, I'd say that the problem is the event you're using to intercept clicks on the button. If your code is fired before ours, the state won't be updated when you look at it.

You might want to try using the buildingQuery event from our own framework if you want something to execute before each query.

Gravatar for ravigupta020287@gmail.com

Comment by Ravi, Nov 16, 2016 8:19 AM

I tried addind it inside $('#search').on('buildingQuery', function(e, args) { //Code });

But it doesn't work for me.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Nov 16, 2016 9:38 AM

I would bind to the querysuccess event instead as you will be sure the query was successful and the results are about to be displayed: https://developers.coveo.com/display/JsSearchV1/Events#Events-querySuccess

Gravatar for ravigupta020287@gmail.com

Comment by Ravi, Nov 16, 2016 12:35 PM

Thanks Jeaf it worked

Ask a question