confirmDialog (deprecated)

confirmDialog() is considered deprecated

Support for the confirmDialog() dialogs may be dropped in future versions of the JourneyApps Runtime. Please upgrade your app to use journey.dialog.confirm to ensure that your app remains compatible with the JourneyApps Runtime.

These docs describe dialogs called from JavaScript/TypeScript. For more fully featured, dynamic dialogs, please refer to the dialog UI component docs. These dialogs are specified from the view XML and can include nested components.

To display a confirmation dialog to the user, use the confirmDialog() built-in JourneyApps function in your JavaScript/TypeScript.

Simple Confirm Dialog

The simplest case of using confirmDialog() is simply to provide the message shown in the dialog, and the return value of confirmDialog() indicates whether the user pressed "OK" or "Cancel"

var ok = confirmDialog("Would you like to continue?");
if (ok) {
    // the user pressed 'OK'
} else {
    // the user pressed 'Cancel'
}

Confirm Dialog with a Title

To display a dialog with a title and message, provide two arguments to confirmDialog(). The first parameter is the title, the second is the message. The return value of confirmDialog() indicates whether the user pressed "OK" or "Cancel"

var ok = confirmDialog("Warning", "Would you like to continue?");
if (ok) {
    // the user pressed 'OK'
} else {
    // the user pressed 'Cancel'
}

Customizing the Button Text

The default "OK" and "Cancel" buttons can be customized by providing two additional arguments to confirmDialog()

// override the default "OK" and "Cancel" buttons with "Yes" and "No"
var ok = confirmDialog("Warning", "Would you like to continue?", "Yes", "No");
if (ok) {
    // the user pressed 'Yes'
} else {
    // the user pressed 'No'
}

Customizing the button color

Version compatibility

The ability to customize a confirmDialog's button color was introduced in version 4.50 of the JourneyApps Container.

To customize the button color, specify an object with text and color as fields instead of a string with the button's text.

var ok = confirmDialog("Warning", "Would you like to continue?", {text: "Yes", color: "positive"}, "No");

Last updated