DS Server

Javascript: SectionCollection.getItem Method

Method|Introduced in 28.0

Description

Gets the section at the current input position or or the section in the collection with the given number.

Syntax

<void> SectionCollection.getItem(<RequestSectionCallback> callback, [<number> number], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the section.

number

Optional. The section number. The first section has the number 1.

errorCallback

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

Examples

The following example demonstrates SectionCollection.getItem in a practical document-editing workflow. It gets the section at the current input position or or the section in the collection with the given number.

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

TXTextControl.sections.getItem(
    function(section) {
        if (!section) {
            console.warn("No section was returned.");
            return;
        }
        
        console.log("get item result:", section);
    },
    1,
    onTxError
);