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?
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.
@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.
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;
});
});
});