add(item, [index])

Class: ComboBox.

Description:

Adds a list item at the end of the list, or inserts the item at specified index.

Parameters:

Name Type Description

item

string | number | ListItem

List item as a string, number or a ListItem formatted object.

[index]

number

Integer position at which to add the item.

Returns:

Returns an index of the added item, or -1 if the item was not added.

Type: number

Examples:

const i = combo1.add({text: "New Item", ...more optional properties}); // Adding item as object
const i = combo1.add("New Item"); // Adding item as string
const i = combo1.add(45); // Adding item as number

Also See: