# Javascript: TextPart.addSubTextPart Method

> Obsolete. This method will be removed in one of the next versions. Inserts a new SubTextPart into the TextPart at the current input position.

> **Note:** This is deprecated and should not be used in new work.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 26.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: TextPart.addSubTextPart Method
- **449 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addsubtextpart-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addsubtextpart-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addsubtextpart-method/llms-full.txt

---

### Description

`Obsolete. This method will be removed in one of the next versions.` Inserts a new SubTextPart into the TextPart at the current input position.

### Syntax

```javascript
<void> TextPart.addSubTextPart(<function> callback, <SubTextPartInfo> subTextPart)
```

### Parameters

| Parameter | Description |
|---|---|
| callback | A function with one parameter. Is called with an AddResult object as a parameter, which indicates whether the SubTextPart was succesfully created, as soon as the information has been retrieved from the server. |
| subTextPart | Specifies the new SubTextPart's properties. The specification of the SubTextPart.name property is required. If the SubTextPart.start and SubTextPart.length properties are available then the SubTextPart will be created at this textrange. |

### Examples

The following example demonstrates `TextPart.addSubTextPart` in a practical document-editing workflow. Obsolete. This method will be removed in one of the next versions. Inserts a new SubTextPart into the TextPart at the current input position.

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

function addSubTextPart(subTextPart) {
    TXTextControl.textParts.getMainText(function(textPart) {
        textPart.addSubTextPart(
            function() {
                console.log("add sub text part completed.");
            },
            subTextPart
        );
    }, onTxError);
}
```

---

## Nearby

- **Previous:** [TextPart Object](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/llms-full.txt)
- **Next:** [Javascript: TextPart.addTextField Method](https://docs.textcontrol.com/ds-server/reference/javascript/textpart/addtextfield-method/llms-full.txt)
