hi all,
in my use case I’m processing the onClick action of something, which is forwarded to some util code outside of the component. If some condition is met I would like to show a confirm dialog to the user before proceeding, and I’m a bit lost on how to do it.
I would imagine something like:
function onClick() {
if(some_condition)
let confirmation: boolean = ConfirmDialog.show("Are you sure?");
if(confirmation)
proceed()
}
There are samples for Java, React and Lit. In the upper right of the samples is also an expand button, that shows the complete sample code. For your case it shows how to open it on click and how to handle the result.
Please notice, that the dialog is not blocking like a browser confirm.
The common way is to create it in the template and open it with attributes and listeners.
But I was also thinking about lists with 100+ children, or if you have like 3 follow up dialog, you need like 3 open attributes and 3 confirm actions, because it may cause a larger overhead.
But the content is only rendered when the dialog is opened, if you use the DialogRenderer. And in your example the overhead wouldn’t be too much with only one question.
Anyways, in theory you create the element via JS api: