🖥 Dialogs API
The Dialogs API utilizes the Modal Vanilla dependency to facilitate the display of dialogs. This dependency is functionally and visually compatible with the Bootstrap framework. This library has been modified to allow multiple dialogs to be displayed simultaneously.
Methods
setController
This method sets the JavaScript controller (module) for the dialog, allowing you to register additional event listeners (such as show, shown, hide, hidden) or other logic related to the dialog.
$response->setController("require('ModalMonitor')");
setTitle
Use this method to set the title of a dialog.
$response->setTitle("dialog title");
setBody
This method sets the body content of a dialog.
$response->setBody("dialog body");
setFooter
Use this method to set the footer content of a dialog.
$response->setFooter('dialog footer');
setDialog
This method sets the entire content of a dialog, including title, body, and footer.
$response->setDialog('dialog content');
closeDialogs
This method closes all opened dialogs.
$response->closeDialogs();
closeDialog
Use this method to close the currently displayed dialog.
$response->closeDialog();
dialog
This method renders the defined dialog.
$response->dialog();
Live Example
You can observe this API in action in the demo page provided.
Example
If you want to trigger a dialog from the backend:
To open this dialog from the frontend, you can use the following HTML code:
For frontend-triggered dialog invocation:
Here's an example of the implementation of a controller that can be attached to the dialog: