Skip to main content

triggerEvent

Callable

  • triggerEvent(el?: EventTarget, type: string, detail?: unknown): boolean

  • Small utility to trigger a custom event for a given EventTarget.

    @example
    triggerEvent(element, Events.IMAGE_RENDERED, { element })

    or it can trigger event on the eventTarget itself

    triggerEvent(eventTarget, CSTOOLS_EVENTS.ANNOTATION_MODIFIED, { viewportId, annotationUID })

    Parameters

    • el: EventTarget = eventTarget

      The element or EventTarget to trigger the event upon

    • type: string

      The event type name

    • detail: unknown = null

      The event detail to be sent

    Returns boolean

    false if event is cancelable and at least one of the event handlers which received event called Event.preventDefault(). Otherwise it returns true.