Support Menu

Class Initialization

Class Initialization

The main purpose of this class is to initialize the framework (a.k.a the code executed when calling Coveo.init).
It's also in charge or registering the available components, as well as the method that we expost to the global Coveo scope.
For example, the Coveo.executeQuery function will be registed in this class by the QueryController.

Index

Methods

Static automaticallyCreateComponentsInside

  • automaticallyCreateComponentsInside(element: HTMLElement, initParameters: IInitializationParameters, ignore?: string[]): IInitResult

Static getListOfLoadedComponents

  • getListOfLoadedComponents(): unknown

Static getListOfRegisteredComponents

  • getListOfRegisteredComponents(): Array<String>
  • Return the list of all known components (the list of ID for each component), whether they are actually loaded or not.

    Returns Array<String>

Static getRegisteredComponent

Static getRegisteredFieldsComponentForQuery

  • getRegisteredFieldsComponentForQuery(componentId: string): string[]
  • Returns all the fields that the framework currently knows should be added to the query, for a given component.

    This is used when the is set to true (which is true by default).

    The framework tries to only include the needed fields from the index, for performance reasons.

    Parameters

    • componentId: string

    Returns string[]

Static getRegisteredFieldsForQuery

  • getRegisteredFieldsForQuery(): Array<string>
  • Returns all the fields that the framework currently knows should be added to the query.

    This is used when the is set to true (which is true by default).

    The framework tries to only include the needed fields from the index, for performance reasons.

    Returns Array<string>

Static initRecommendationInterface

  • initRecommendationInterface(element: HTMLElement, options?: any): IInitResult
  • Create a new recommendation search interface. This is the function executed when calling Coveo.initRecommendation.

    Parameters

    • element: HTMLElement
    • Default value options: any = {}

    Returns IInitResult

Static initSearchInterface

  • initSearchInterface(element: HTMLElement, options?: any): IInitResult
  • Create a new standard search interface. This is the function executed when calling Coveo.init.

    Parameters

    • element: HTMLElement
    • Default value options: any = {}

    Returns IInitResult

Static initStandaloneSearchInterface

  • initStandaloneSearchInterface(element: HTMLElement, options?: any): IInitResult
  • Create a new standalone search interface (standalone search box). This is the function executed when calling Coveo.initSearchbox.

    Parameters

    • element: HTMLElement
    • Default value options: any = {}

    Returns IInitResult

Static initializeFramework

  • initializeFramework(element: HTMLElement, options: any, initSearchInterfaceFunction: function): Promise
  • Initialize the framework. Note that this function should not normally be called directly, but instead using a globally registered function (e.g.: Coveo.init), or Initialization.initSearchInterface or Initialization.initStandaloneSearchInterface
    (e.g. : Coveo.init or Coveo.initSearchbox).

    Parameters

    • element: HTMLElement

      The element on which to initialize the interface.

    • options: any

      The options for all components (eg: {Searchbox : {enableSearchAsYouType : true}}).

    • initSearchInterfaceFunction: function

      The function to execute to create the SearchInterface component. Different init call will create different SearchInterface.

        • (...args: any[]): IInitResult
        • Parameters

          • Rest ...args: any[]

          Returns IInitResult

    Returns Promise

Static isComponentClassIdRegistered

  • isComponentClassIdRegistered(componentClassId: string): boolean
  • Check if a component is already registered, using it's ID (e.g. : 'Facet').

    Parameters

    • componentClassId: string

    Returns boolean

Static isNamedMethodRegistered

  • isNamedMethodRegistered(methodName: string): boolean

Static monkeyPatchComponentMethod

  • monkeyPatchComponentMethod(methodName: string, element: HTMLElement, handler: function): void
  • 'Monkey patch' (replace the function with a new one) a given method on a component instance.

    Parameters

    • methodName: string
    • element: HTMLElement
    • handler: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

Static registerAutoCreateComponent

  • Register a new Component to be recognized by the framework. This essentially mean that when we call Coveo.init, the Initialization class will scan the DOM for known component (which have registed themselves with this call) and create a new component on each element.

    This is meant to register the component to be loaded "eagerly" (Immediately available when the UI scripts are included)

    Parameters

    Returns void

Static registerComponentFields

  • registerComponentFields(componentId: string, fields: string[]): void
  • Set the fields that the component needs to add to the query.

    This is used when the is set to true (which is true by default).

    The framework tries to only include the needed fields from the index, for performance reasons.

    Parameters

    • componentId: string

      The id for the component (eg: CoveoFacet)

    • fields: string[]

    Returns void

Static registerDefaultOptions

  • registerDefaultOptions(element: HTMLElement, options: object): void
  • Register a new set of options for a given element.
    When the element is eventually initialized as a component, those options will be used / merged to create the final option set to use for this component.
    Note that this function should not normally be called directly, but instead using the global Coveo.options function

    Parameters

    • element: HTMLElement
    • options: object

    Returns void

Static registerNamedMethod

  • registerNamedMethod(methodName: string, handler: function): void
  • Register a new globally available method in the Coveo namespace (e.g.: Coveo.init).

    Parameters

    • methodName: string

      The method name to register.

    • handler: function

      The function to execute when the method is called.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

Hierarchy

  • Initialization