I would like to get some assistance with Alpha dialog.
Am struggling to find a way to close a dialog when a button is clicked,
I know it has a close on the top right but would like to close it when a save button is clicked.
Hi all — how can I make the dialog’s close (×) icon perform a different action (for example console.log('Clicked')) instead of just closing the dialog?
When a page is being used as a dialog, the is no event that is dipatched or exposed for the close icon.
But you can use the snippet code below which uses event delegation — attach the listener to a stable parent (the dialog) and check the click target:
const dialog = this;
dialog.addEventListener(‘click’, (event) => {
if (event.target.id === ‘xdialog-delete’) {
console.log(‘Delete SVG clicked via delegation’);
}
});