'JQuery Confirm keeps deleting my files before I can make a selection

I am trying to use jQueryConfirm to delete messages but before I can select "Yes" or "No" option the modal reloads and deletes the message. The original code works fine but the window that pops up for the user to make a selection can not be tabbed into. Here is the original code

function update_status(form, status) {
            var url_info = "";
            var count = 1;
            var del_messages = 'true';

            if (status == 'Delete'){
                 if (!confirm('Are you sure you want to permanently delete these Messages?')) {
                     del_messages = 'false';
                 }
            }
            if (status == 'DeleteS'){
                if (!confirm("Are you sure you want to permanently delete these Sent Messages?  This will also delete the message from the recipient's message board.")) {
                    del_messages = 'false';
                }
                status='Delete'
            }
            jQuery(".message_selected:visible:checked").each(function () {
                if (count == 1) {
                    url_info = jQuery(this).val();
                    count += 1;
                }
                else {
                    url_info = url_info + "," + jQuery(this).val();
                    count += 1;
                }
            });
            if (del_messages=='true') {
                var test = window.location="updateStatus?msg_id=" + url_info + "&status=" + status;
            }
        }

The change we want to use in our code base is something similar to this which creates a tab friendly modal pop up.

jQueryConfirm('', 'Would you like to populate a new Proficiency for this employee?',
                      'Yes', function(){ return openNewProficiency(data); },
                      'No', function(){}
                    );

So I tried replacing the first if statement status == 'Delete' with the new code, but it just keeps deleting and ignoring the Yes and No selection.

function update_status(form, status) {
            var url_info = "";
            var count = 1;
            var del_messages = 'true';
            
            //Trying to convert
            if (status == 'Delete'){
                jQueryConfirm('', 'Are you sure you want to permanently delete these Messages?',
                'Yes', function(){ del_messages = 'true'; },
                'No', function(){ del_messages = 'false'; }
                );
            }

            if (status == 'DeleteS'){
                if (!confirm("Are you sure you want to permanently delete these Sent Messages?  This will also delete the message from the recipient's message board.")) {
                    del_messages = 'false';
                }
                status='Delete'
            }
            jQuery(".message_selected:visible:checked").each(function () {
                if (count == 1) {
                    url_info = jQuery(this).val();
                    count += 1;
                }
                else {
                    url_info = url_info + "," + jQuery(this).val();
                    count += 1;
                }
            });
            if (del_messages=='true') {
                var test = window.location="updateStatus?msg_id=" + url_info + "&status=" + status;
            }
        }

I tried adding another if statement after status == 'Delete' but was unsuccessful. Is there something overriding the selection or am I using it incorrectly?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source