Alpha Dialog or Popup

Hi all

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.

Please see the below image for better reference.

Thank you in advance.

3 Likes

Hi @Simphiwe , You can close the dialog programmatically by using the following Alpha-supported method in your custom code:

ap.dialog.close();

Just add this to the onclick trigger of your Save button, and it will close the dialog when clicked.

5 Likes

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?

2 Likes

HI all,
Anyone with info regarding this please assist. Thanks.

1 Like

@Shamnad_KS @Sam @Simphiwe please support Edward

Hi @Edward,

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’);
}
});

That should work.

1 Like