Class: ConfirmationDialog

ConfirmationDialog()

<brut-confirmation-dialog>

Enhances a DIALOG element to allow it to be used for confirmation. Mostly useful with Confirm.

This element must:

  • Wrap a <DIALOG> element
  • Contain an <H1> where the message will go
  • Have a <BUTTON> with value ok that will be considered the confirmation button.
  • Have a <BUTTON> with value cancel that will be considered the denial button.

Omitting these will cause this element to not work properly. Set show-warnings to see warnings on this.

Constructor

new ConfirmationDialog()

Properties:
Name Type Description
message string

the message to use to ask for confirmation

confirm-label string

the label to use for the "OK" or "Confirm" button

Source:
Example

Minimal Example

<brut-confirmation-dialog message="This cannot be undone" confirm-label="DOIT">
  <dialog>
    <h1></h1>
    <button value="ok"></button>
    <button value="cancel">Nevermind</button>
  </dialog>
</brut-confirmation-dialog>

Methods

showModal(onClose)

Call this to show the dialog. When the dialog is closed, onClose is called with the result.

Parameters:
Name Type Description
onClose function

a function called with either true or false, if the dialog was confirmed or denied, respectively.

Source:
Example
dialog.showModal( (confirmed) => {
  if (confirmed) {
    form.submit()
  }
  else {
    // do nothing
  }
})