Dialog

Dialog

Create a modal dialog window displaying a title, a message, and a set of buttons which trigger callback functions.

Constructor

new Dialog(dialogData, options)

Source:
Example
let d = new Dialog({
 title: "Test Dialog",
 content: "<p>You must choose either Option 1, or Option 2</p>",
 buttons: {
  one: {
   icon: '<i class="fas fa-check"></i>',
   label: "Option One",
   callback: () => console.log("Chose One")
  },
  two: {
   icon: '<i class="fas fa-times"></i>',
   label: "Option Two",
   callback: () => console.log("Chose Two")
  }
 },
 default: "two",
 close: () => console.log("This always is logged no matter which option is chosen")
});
d.render(true);
Parameters:
Name Type Description
dialogData Object

An object of dialog data which configures how the modal window is rendered

Properties
Name Type Description
title string

The window title

content string

HTML content

close function

Common callback operations to perform when the dialog is closed

buttons Object

Action buttons which trigger callback functions. Buttons are defined as an Object with the format {name: buttonData}. Valid keys for buttonData include:

Properties
Name Type Description
button.icon string

A button icon

button.label string

A button label

button.callback function

A callback function taking no arguments

options Object

Dialog rendering options, see :class:Application

Properties
Name Type Description
default string

The name of the default button which should be triggered on Enter

Members

(static) defaultOptions

Source:

title

Source:

Methods

(async, static) confirm(title, content, yes, no, defaultYes, options) → {Promise}

Source:

A helper factory method to create simple confirmation dialog windows which consist of simple yes/no prompts. If you require more flexibility, a custom Dialog instance is preferred.

Parameters:
Name Type Description
title string

The confirmation window title

content string

The confirmation message

yes function

Callback function upon yes

no function

Callback function upon no

defaultYes boolean

Make "yes" the default choice?

options Object

Additional rendering options passed to the Dialog

Returns:

A promise which resolves once the user makes a choice or closes the window

Type
Promise

activateListeners()

Source:

close()

Source:

getData()

Source: