const input = dialog.content.querySelector('input[type="text"]');
```
+### Managing an Instance of a Dialog
+
+The old API for dialogs implicitly kept track of the instance by binding it to the `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.
+
+```ts
+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
You can bind event listeners to specialized events to get notified of events and to modify its behavior.
# Dialogs - JavaScript API
-!!! info This API has been deprecated in WoltLab Suite 6.0, please refer to the new [dialog implementation](components_dialog.md).
+!!! info "This API has been deprecated in WoltLab Suite 6.0, please refer to the new [dialog implementation](components_dialog.md)."
## Introduction
- 'TypeScript and JavaScript': 'migration/wsc55/javascript.md'
- 'Templates': 'migration/wsc55/templates.md'
- 'Icons': 'migration/wsc55/icons.md'
+ - 'Dialogs': 'migration/wsc55/dialogs.md'
- 'Third Party Libraries': 'migration/wsc55/libraries.md'
- 'Deprecations and Removals': 'migration/wsc55/deprecations_removals.md'
- 'From WoltLab Suite 5.4':