Action Link Button Confirmation

Greetings all-

I was attempting to use the script that @Chem and @moe provided in the following posting:

However, it doesn’t appear to be triggering the action in the action link. I did some troubleshooting and the {buttons: [“No way!”, “Yes, proceed”],} seems to be part of the issue. When I remove the code the action is triggered.

Anyone have any suggestions on what I may be doing wrong?

~Adam

Greetings Tada Community-

I engaged @Chem about this issue. There appears to be issues with the Sweetalert JS code. Tada will review the code as they get some time but for now, there is no fix and this option should not be relied upon.

Thank you @Chem for doing the due diligence of narrowing the issue down to the third-party javascript.

Cheers all,
~Adam

2 Likes

Did anyone ever find out how to do this using Sweetalert JS or any other Java Script?

I have not received any updates. I believe it is still dead in the water.

I ended up removing the part of the script related to Sweet Alert (SWAL) JS and it works. It’s jus not as pretty.

Based on this discussion: Action Button Confirmation

Change line 5. Instead of:
var r = swal(confirmationText, {buttons: ["No way!", "Yes, proceed"],});
Change it to: :
var r = confirm(confirmationText);

@Chem @moe Tadabase team, any update on this? Im sure many would like to be able to have the Sweet Alert buttons working with a yes or no that trigger the action link.

@Chem SweetAlert2 is out so perhaps we should be using that instead of version 1 and perhaps that could resolve the issue we are having.

https://sweetalert2.github.io/#examples

I tried to implement a confirmation before form submission after reading the discussion and answers from @Chem and @Moe, which were quite helpful. However, their solutions didn’t work with forms. I implemented it my way, and I hope it helps others:

TB.render('YOUR_COMPONENT_ID', function(data) {
    setTimeout(function() {
        // Hide the original button and add the 'original' class
        var btn = $(".af-form-submit", data.ele)
            .hide()
            .addClass('original');
        
        // Clone the button, remove the 'original' class, and show it
        btn.clone(true)
            .off()
            .removeClass('original')
            .appendTo(btn.parent())
            .show();
        
        // Attach the click event handler to the cloned button
        jQuery('.af-form-submit:not(.original)', data.ele).on('click', function() {
            let userConfirmed = confirm("Are you sure you want to submit this?");
            
            if (userConfirmed) {
                // Trigger the click event on the original button if the user confirms
                jQuery('.af-form-submit.original', data.ele).trigger("click");
            }
            
            // Return the user's confirmation status
            return userConfirmed;
        });
    });
});