From: WoltLab GmbH The old API for dialogs implicitly kept track of the instance by binding it to the You can bind event listeners to specialized events to get notified of events and to modify its behavior..open
property to determine if the dialog is currently op
// Find a text input inside the dialog.
const input = dialog.content.querySelector('input[type="text"]');
+Managing an Instance of a Dialog#
+this
parameter as seen in calls like UiDialog.open(this);
.
+The new implementation requires to you to keep track of the dialog on your own. 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
class MyComponent {
+ #dialog?: WoltlabCoreDialogElement;
+
+ constructor() {
+ const button = document.querySelector(".myButton") as HTMLButtonElement;
+ button.addEventListener("click", () => {
+ this.#showGreeting(button.dataset.name);
+ });
+ }
+
+ #showGreeting(name: string | undefined): void {
+ const dialog = this.#getDialog();
+
+ const p = dialog.content.querySelector("p")!;
+ if (name === undefined) {
+ p.textContent = "Hello World";
+ } else {
+ p.textContent = `Hello ${name}`;
+ }
+
+ dialog.show("Greetings!");
+ }
+
+ #getDialog(): WoltlabCoreDialogElement {
+ if (this.#dialog === undefined) {
+ this.#dialog = dialogFactory()
+ .fromHtml("<p>Hello from MyComponent</p>")
+ .withoutControls();
+ }
+
+ return this.#dialog;
+ }
+}
+
Event Access#
@@ -3234,7 +3331,7 @@ Canceling this event is interpreted as a form validation failure.afterClose
#
!!! info This API has been deprecated in WoltLab Suite 6.0, please refer to the new dialog implementation.
+This API has been deprecated in WoltLab Suite 6.0, please refer to the new dialog implementation.
+Dialogs are full screen overlays that cover the currently visible window area
using a semi-opague backdrop and a prominently placed dialog window in the
@@ -3048,7 +3064,7 @@ key is .content
which holds a reference to the dialog's inner conte
Last update:
- 2022-10-11
+ 2022-10-13
diff --git a/6.0/javascript/new-api_dom/index.html b/6.0/javascript/new-api_dom/index.html
index 13990ae1..dbe538c3 100644
--- a/6.0/javascript/new-api_dom/index.html
+++ b/6.0/javascript/new-api_dom/index.html
@@ -1923,6 +1923,20 @@
+