TX Text Control .NET Server

Javascript: TableOfContentsCollection.getItem Method

Method|Introduced in 29.0

Description

Gets the table of contents at the current input position or the table of contents with the specified identifier.

Syntax

<void> TableOfContentsCollection.getItem(<RequestTableOfContentsCallback> callback, [<ErrorCallback> errorCallback], [<number> id])

Parameters

ParameterDescription
callback

Receives the requested table of contents or null if there is no table of contents at the current input position / with the specified identifier.

errorCallback

Optional. Is called when the operation failed with an error.

id

Optional. The table of contents' identifier.

Examples

The following example demonstrates TableOfContentsCollection.getItem in a practical document-editing workflow. It gets the table of contents at the current input position or the table of contents with the specified identifier.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function inspectItem(tableOfContentss) {
    tableOfContentss.getItem(
        function(toc) {
            if (!toc) {
                console.warn("No table of contents was returned.");
                return;
            }
            
            console.log("get item result:", toc);
        },
        onTxError,
        25
    );
}