Gravatar for corrac@paragon-inc.com

Question by Cris Corra, Sep 4, 2014 4:17 PM

How to disable Omnibox redirect to search page.

I have an omnibox on my page that has a TopFieldSuggestions component that fills the dropdown list in the omnibox. I want the user to select an item in the list to direct them to the search page. Currently if they type text and hit enter or click the Clear button, it redirects to the search page specified. Is there a way to override those event handlers or specify only to redirect on select of a list item?

Here is my code:

    Coveo.$('#guideSearchBox')
                .coveo('initSearchBox', '/guidelines', {
                    TopFieldSuggestions : {
                        omniboxSuggestionOptions : {
                            onSelect : function(valueSelected, populateOmniBoxEventArgs){
                                window.location.href = "/guidelines#first=0&f:TopicSearchFacet=[" + valueSelected + "]";
                            }
                        }
                    }
                })

Cris Corra

1 Reply
Gravatar for olamothe@coveo.com

Answer by olamothe, Sep 4, 2014 4:56 PM

Hi Cris,

In your case you could override the executeQuery function provided by the framework so that it does nothing, except some css modfication. Just make sure that this code is only executed on the correct page, or it will break all queries in your main search page !

  $(function () {
      Coveo.Controllers.QueryController.prototype.executeQuery = function() {
        Coveo.$("#guideSearchBox").removeClass("coveo-executing-query")
      }
      Coveo.$('#guideSearchBox')
                .coveo('initSearchBox', '/guidelines', {
                    TopFieldSuggestions : {
                        omniboxSuggestionOptions : {
                            onSelect : function(valueSelected, populateOmniBoxEventArgs){
                                window.location.href = "/guidelines#first=0&f:TopicSearchFacet=[" + valueSelected + "]";
                            }
                        }
                    }
                });
   });
Ask a question