Support Menu

Coveo component OmniboxResultList

Coveo OmniboxResultList Component (CoveoOmniboxResultList)

The OmniboxResultList component behaves exactly like the ResultList component (which it extends), except that it renders itself inside the Omnibox component.

This component can provide a kind of search-as-you-type functionality, allowing you to easily render complex Result Templates inside the Omnibox component.

Example:

<div class="CoveoOmniboxResultList">
  <script class="result-template" type="text/x-underscore">
    <div>
      <a class='CoveoResultLink'></a>
    </div>
  </script>
</div>

Index

Component Options

headerTitle

headerTitle: string

Specifies the title to use for this section.

Default value is the localized string for Suggested Results.

Markup configuration example(s) :
data-header-title='foo'

omniboxZIndex

omniboxZIndex: number

Specifies the z-index at which to render the ResultList inside the Omnibox.

Default value is 51. Minimum value is 16 (Facet components are at 50 by default)

Markup configuration example(s) :
data-omnibox-z-index='10'

onSelect

onSelect: function

Specifies the function to execute when the user selects a result suggestion.

The default function opens the corresponding result URI in the browser.

It is only possible to specify a value for this option in the init call of your search interface. You cannot set it directly as an HTML attribute.

Example:

// You can call the init script using "pure" JavaScript:
Coveo.init(document.querySelector('#search'), {
   OmniboxResultList : {
       //Close the omnibox, change the selected HTMLElement background color and alert the result title.
       onSelect : function(result, resultElement, omniBoxObject) {
           omniBoxObject.close();
           resultElement.css('background-color', 'red');
           alert(result.title);
       }
    }
})

// Or you can call the init script using the jQuery extension:
$("#search").coveo("init", {
   OmniboxResultList : {
       //Close the Omnibox, change the selected HTMLElement background color and alert the result title.
       onSelect : function(result, resultElement, omniBoxObject) {
           omniBoxObject.close();
           resultElement.css('background-color', 'red');
           alert(result.title);
       }
    }
})

Type declaration

    • (result: IQueryResult, resultElement: HTMLElement, omniboxObject: IPopulateOmniboxEventArgs): void
    • Parameters

      • result: IQueryResult
      • resultElement: HTMLElement
      • omniboxObject: IPopulateOmniboxEventArgs

      Returns void

queryOverride

queryOverride: string

Specifies the override to use on the query sent to the OmniboxResultList component.

Default value is undefined, which means no default override is specified.

Markup configuration example(s) :
data-query-override='foo'

Methods

buildResult

buildResults

debugInfo

  • debugInfo(): any

disable

  • disable(): void
  • Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Component are enabled by default on creation.

    Returns void

displayMoreResults

  • displayMoreResults(count: number): unknown
  • Executes a query to fetch new results. After the query returns, renders the new results.

    Asserts that there are more results to display by verifying whether the last query has returned as many results as requested.

    Asserts that the ResultList is not currently fetching results.

    Parameters

    • count: number

      The number of results to fetch and display.

    Returns unknown

enable

  • enable(): void
  • Enable the component. Normally this means that the component will execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

    Returns void

getAutoSelectedFieldsToInclude

  • getAutoSelectedFieldsToInclude(): string[]

getBindings

getDisplayedResults

getDisplayedResultsElements

  • getDisplayedResultsElements(): HTMLElement[]

renderResults

  • renderResults(resultsElement: HTMLElement[], append?: boolean): unknown
  • Creates a result container and appends each element from the received HTMLElement array to it. For each element it appends to the result container, this method triggers a newResultDisplayed event. Once all elements have been appended to the result container, the method triggers a newResultsDisplayed event.

    Parameters

    • resultsElement: HTMLElement[]

      The array of HTMLElement to render.

    • Default value append: boolean = false

    Returns unknown

Static get

  • get(element: HTMLElement, componentClass?: any, noThrow?: boolean): BaseComponent
  • Get the bound component to the given HTMLElement. Throws an assert if the HTMLElement has no component bound, unless using the noThrow argument.
    If there is multiple component bound to the current HTMLElement, you must specify the component class.

    Parameters

    • element: HTMLElement

      HTMLElement for which to get the bound component.

    • Optional componentClass: any

      Optional component class. If the HTMLElement has multiple components bound, you must specify which one you are targeting.

    • Optional noThrow: boolean

      Boolean option to tell the method to not throw on error.

    Returns BaseComponent

Properties

bind

Allows the component to bind events and execute them only when it is enabled.

type

{Coveo.ComponentEvents}

componentOptionsModel

componentOptionsModel: ComponentOptionsModel

Contains the state of options for differents component. Mainly used by ResultLink.

componentStateModel

componentStateModel: ComponentStateModel

Contains the state of different component (enabled vs disabled). Allows to get/set values. Trigger component state event when modified. Each component can listen to those events.

disabled

disabled: boolean

A disabled component will not participate in the query, or listen to ComponentEvents.

type

{boolean}

logger

logger: Logger

Allows component to log in the dev console.

queryController

queryController: QueryController

Contains the singleton that allows to trigger queries.

queryStateModel

queryStateModel: QueryStateModel

Contains the state of the query. Allows to get/set values. Trigger query state event when modified. Each component can listen to those events.

root

root: HTMLElement

A reference to the root HTMLElement (the SearchInterface).

searchInterface

searchInterface: SearchInterface

A reference to the root of every component, the SearchInterface.

usageAnalytics

usageAnalytics: IAnalyticsClient

A reference to the Analytics.client.

Static ID

ID: string

The static ID that each component need to be identified.
For example, SearchButton -> static ID : SearchButton -> className : CoveoSearchButton

Constructors

constructor

Implements