From 6c0f18d5d883e0634b260d4dd90edca1688924b9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 17 May 2023 13:40:16 +0200 Subject: [PATCH] Document the use of `confirmationFactory.custom()` Closes #331 --- docs/javascript/components_confirmation.md | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/javascript/components_confirmation.md b/docs/javascript/components_confirmation.md index ff842bc7..14eaaa38 100644 --- a/docs/javascript/components_confirmation.md +++ b/docs/javascript/components_confirmation.md @@ -100,3 +100,36 @@ if (result) { console.log("The user has requested to delete the object."); } ``` + +## Custom Confirmation Prompts + +The `custom()` permits a custom confirmation dialog with a user-defined dialog content. + +```ts +const result = await confirmationFactory() + .custom(theQuestionToAsk) + .message(someLengthyExplanation); +if (result) { + console.log("The user has confirmed the dialog."); +} +``` + +### Use Custom HTML in the Dialog Body + +Some dialogs require additional input elements, for example, the prompt to remove an element has an optional text field for a reason. + +```ts +const { result, dialog } = await confirmationFactory() + .custom(theQuestionToAsk) + .withFormElements((dialog) => { + const p = document.createElement("

Hello World

"); + dialog.content.append(p); + }); +if (result) { + console.log("The user has confirmed the dialog."); + console.log( + "The DOM of the dialog can be accessed through `dialog.content`", + dialog.content + ); +} +``` -- 2.20.1