optionList

Overview

Version compatibility

optionList was introduced in version 4.23.0 of the JourneyApps Container.

optionList displays a list of options to the user. optionList needs to be triggered from the JavaScript/TypeScript.

If more than 12 items are displayed, a type-ahead filter is included.

Basic Example

main.js
var options = [
	"Add a new beneficiary", "Select an existing beneficiary", "Delete all my beneficiaries"
];

// The optionList is created as follows:
var result = optionList(options);

// When a user clicks, the result can be evaluated as follows:
if (result == 0) {
    // The user clicked on "Add a new beneficiary"
}
else if (result == 2) {
    // The user clicked on "Delete all my beneficiaries"
}
if (result == -1) {
    // The user canceled the optionList
}

Appearance

  • On a mobile device, the optionList takes up the entire screen.

  • On desktop, the optionList is displayed in the centre of the screen.

Configuration

main.js
var result = optionList(arrayOfButtons, additionalOptions);
Parameter
Required
Details

arrayOfButtons

Required

An array of strings denoting the text of the options

additionalOptions

Optional

An object with one or more of the following properties:

  • title: (String) The title of the optionList Defaults to Choose an option.

Returns: The index of the selected option. If the user cancels the optionList, -1 will be returned.

Last updated