@thiagohp/tapestry-5
    Preparing search index...

    Interface DOM

    Defines the type of the exported object for t5/core/dom.js implementations.

    interface DOM {
        ajaxRequest: (
            url: string,
            options?: AjaxRequestOptions,
        ) => RequestWrapper;
        body: ElementWrapper;
        create: (
            elementName: string,
            attributes?: object,
            body?: AddableContent,
        ) => ElementWrapper;
        getEventUrl: (eventName: string, element?: HTMLElement) => null | string;
        on: (
            selector: string | HTMLElement | Document | HTMLElement[],
            events: string,
            match: null | string,
            handler: OnEventHandler,
        ) => () => any;
        onDocument: (
            events: string,
            match: null | string,
            handler: OnEventHandler,
        ) => () => any;
        scanner: (selector: string, callback: (e: ElementWrapper) => void) => void;
        wrap: (element: string | HTMLElement) => null | ElementWrapper;
        (element: string | HTMLElement): null | ElementWrapper;
    }
    • Function that wraps a DOM element as an ElementWrapper; additional functions are attached as properties.

      Parameters

      • element: string | HTMLElement

        a DOM element, or a string id of a DOM element.

      Returns null | ElementWrapper

      the ElementWrapper, or null if no element with the id exists.

    Index

    Properties

    ajaxRequest: (url: string, options?: AjaxRequestOptions) => RequestWrapper

    Returns a wrapped version of the document.body element. Because all Tapestry JavaScript occurs inside a block at the end of the document, inside the <body> element, it is assumed that it is always safe to get the body.

    create: (
        elementName: string,
        attributes?: object,
        body?: AddableContent,
    ) => ElementWrapper

    Creates a new element, detached from the DOM.

    Type declaration

      • (
            elementName: string,
            attributes?: object,
            body?: AddableContent,
        ): ElementWrapper
      • Parameters

        • elementName: string

          {string} name of element to create, if ommitted, then "div"

        • Optionalattributes: object

          {object} attributes to apply to the created element (may be omitted)

        • Optionalbody: AddableContent

          {AddableContent} content for the new element, may be omitted for no body

        Returns ElementWrapper

    getEventUrl: (eventName: string, element?: HTMLElement) => null | string

    Returns the URL of a component event based on its name and an optional element or null if the event information is not found. When the element isn't passed or it's null, the event data is taken from the element.

    Type declaration

      • (eventName: string, element?: HTMLElement): null | string
      • Parameters

        • eventName: string

          name of the component event.

        • Optionalelement: HTMLElement

          (object) HTML DOM element to be used as the beginning of the event data search. Optional.

        Returns null | string

    on: (
        selector: string | HTMLElement | Document | HTMLElement[],
        events: string,
        match: null | string,
        handler: OnEventHandler,
    ) => () => any

    Used to add an event handler to an element (possibly from elements below it in the hierarchy).

    Type declaration

      • (
            selector: string | HTMLElement | Document | HTMLElement[],
            events: string,
            match: null | string,
            handler: OnEventHandler,
        ): () => any
      • Parameters

        • selector: string | HTMLElement | Document | HTMLElement[]

          CSS selector used to select elements to attach handler to; alternately, a single DOM element, or an array of DOM elements. The document is considered an element for these purposes.

        • events: string

          one or more event names, separated by spaces

        • match: null | string

          optional: CSS expression used as a filter; only events that bubble up to a selected element from an originating element that matches the CSS expression will invoke the handler.

        • handler: OnEventHandler

          function invoked; the function is passed an EventWrapper object, and the context (this) is the ElementWrapper for the matched element.

        Returns () => any

    onDocument: (
        events: string,
        match: null | string,
        handler: OnEventHandler,
    ) => () => any

    onDocument() is used to add an event handler to the document object; this is used for global (or default) handlers.

    Type declaration

      • (events: string, match: null | string, handler: OnEventHandler): () => any
      • Parameters

        • events: string

          one or more event names, separated by spaces

        • match: null | string

          optional: CSS expression used as a filter; only events that bubble up to a selected element from an originating element that matches the CSS expression will invoke the handler.

        • handler: OnEventHandler

          function invoked; the function is passed an EventWrapper object, and the context (this) is the ElementWrapper for the matched element.

        Returns () => any

        a function of no parameters that removes any added handlers.

    scanner: (selector: string, callback: (e: ElementWrapper) => void) => void

    Sets up a scanner callback; this is used to perfom one-time setup of elements that match a particular CSS selector. The callback is passed each element that matches the selector. The callback is expected to modify the element so that it does not match future selections caused by zone updates, typically by removing the CSS class or data- attribute referenced by the selector.

    Type declaration

      • (selector: string, callback: (e: ElementWrapper) => void): void
      • Parameters

        • selector: string

          a CSS selector.

        • callback: (e: ElementWrapper) => void

          the function to be called.

        Returns void

    wrap: (element: string | HTMLElement) => null | ElementWrapper

    Function that wraps a DOM element as an ElementWrapper; additional functions are attached as properties.

    Type declaration

      • (element: string | HTMLElement): null | ElementWrapper
      • Parameters

        • element: string | HTMLElement

          a DOM element, or a string id of a DOM element.

        Returns null | ElementWrapper

        the ElementWrapper, or null if no element with the id exists.