Skip to content

Custom dialog for data-confirm modal #378

Answered by jiripudil
ne0-cz asked this question in Support
Discussion options

You must be logged in to vote

Hi, I'm afraid this is the way it is with the DOM's event system: it's synchronous and it doesn't play well with any kind of asynchronous workflow. So yes, you need to call preventDefault() synchronously and then replay the interaction. A quick-n-dirty solution could look something like this:

naja.uiHandler.addEventListener('interaction', (event) => {
    if (event.detail.element.hasAttribute('data-confirm') && !event.detail.options.bypassConfirmation) {
        event.preventDefault();
        customAsyncConfirmation(event.detail.element.getAttribute('data-confirm'))
            .then(() => {
                naja.uiHandler.clickElement(event.detail.element, {bypassConfirmation: true});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ne0-cz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants