Support Menu

Class ComponentEvents

Used by the various Coveo Component to trigger and bind event.
It adds a small logic to execute handler or triggers only when the component is "enabled".
A component is disabled by calling {Component.disable}
Typically, a component is disabled when it is not active in the current {Tab}.
It can also be disabled by external code.
The class serves as a way to not execute handler on component that are invisible and inactive in the query.

Index

Methods

on

  • on(el: HTMLElement | Window | Document, event: string, handler: Function): any
  • Execute the handler for the given event on the given target element.
    Execute only if the component is "enabled" (see Component.enable).

    Parameters

    • el: HTMLElement | Window | Document

      The target on which the event will originate.

    • event: string

      The event for which to register an handler.

    • handler: Function

      The function to execute when the event is triggered.

    Returns any

onQueryState

  • onQueryState<T>(eventType: string, attribute?: string, handler?: function): void
  • Bind an event related specially to the query state model.
    This will build the correct string event and execute the handler only if the component is activated.

    Type parameters

    • T

    Parameters

    • eventType: string

      The event type for which to register an event.

    • Optional attribute: string

      The attribute for which to register an event.

    • Optional handler: function

      The handler to execute when the query state event is triggered.

        • (args: T): any
        • Parameters

          • args: T

          Returns any

    Returns void

onRootElement

  • onRootElement<T>(event: string, handler: function): void
  • Bind on the "root" of the Component. The root is typically the SearchInterface.
    Bind an event using native javascript code.

    Type parameters

    • T

    Parameters

    • event: string

      The event for which to register an handler.

    • handler: function

      The function to execute when the event is triggered.

        • (args: T): any
        • Parameters

          • args: T

          Returns any

    Returns void

one

  • one(el: HTMLElement, event: string, handler: Function): any
  • Execute the handler for the given event on the given target element.
    Execute only if the component is "enabled" (see Component.enable).
    Execute the handler only ONE time.

    Parameters

    • el: HTMLElement

      The target on which the event will originate.

    • event: string

      The event for which to register an handler.

    • handler: Function

      The function to execute when the event is triggered.

    Returns any

oneQueryState

  • oneQueryState<T>(eventType: string, attribute?: string, handler?: function): void
  • Bind an event related specially to the query state model.
    This will build the correct string event and execute the handler only if the component is activated.
    Will execute only once.

    Type parameters

    • T

    Parameters

    • eventType: string

      The event type for which to register an event.

    • Optional attribute: string

      The attribute for which to register an event.

    • Optional handler: function

      The handler to execute when the query state event is triggered.

        • (args: T): any
        • Parameters

          • args: T

          Returns any

    Returns void

oneRootElement

  • oneRootElement<T>(event: string, handler: function): void
  • Bind on the "root" of the Component. The root is typically the SearchInterface.
    Bind an event using native javascript code. The handler will execute only ONE time.

    Type parameters

    • T

    Parameters

    • event: string

      The event for which to register an handler.

    • handler: function

      The function to execute when the event is triggered.

        • (args: T): any
        • Parameters

          • args: T

          Returns any

    Returns void

trigger

  • trigger(el: HTMLElement, event: string, args?: Object): any
  • Trigger an event on the target element, with optional arguments.

    Parameters

    • el: HTMLElement

      The target HTMLElement on which to trigger the event.

    • event: string

      The event to trigger.

    • Optional args: Object

      The optional argument to pass to the handlers.

    Returns any

Private wrapToCallIfEnabled

  • wrapToCallIfEnabled(func: Function): (Anonymous function)
  • Execute the function only if the component is enabled.

    Parameters

    • func: Function

      The function to execute if the component is enabled.

    Returns (Anonymous function)

Constructors

constructor

Hierarchy

  • ComponentEvents