Using isConfirm with a SweetAlert

I have a SweetAlert with a Cancel option.  My javascript has the isConfirm function and works correctly if isConfirm is true.  It just bypasses the code for the else statement. Any thoughts?

 swal({
                title: "Add New Action/Task",
                text: "This will add a new Action/Task to the stored Action List for future use.  If you do not wish to save this Action for later, click Cancel and choose Other.",
                type: "warning",
                showCancelButton: true,
                cancelButtonText: "Cancel",
                buttons: true,
                dangerMode: true,
                closeOnConfirm: true,
                closeOnCancel: true,
                confirmButtonText: "Yes"
            },
                function (isConfirm) {

                    if (isConfirm) {
                        CM.disabled = false;
                        CM.style.backgroundColor = "white";
                        actionOther.style.backgroundColor = "white";
                        actionOther.placeholder = "Enter New Action/Task";
                    }

                    else {
                        CM.disabled = false;
                        actionDropdown.value = "Other";
                        actionDropdown.text = "Other (Enter Other Action/Task)";
                        actionOther.placeholder = "Enter Other Action/Task";
                    }

                }.bind(this));

Open in new window

Crystal RouseTask LeadAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I have not yet used SweetAlert, but have it bookmarked to try it out.  

I did see that isConfirm is from a previous version.  https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2

swal(
  {title: 'Are you sure?', showCancelButton: true}, 
  function(isConfirm) {
    if (isConfirm) {
      // handle confirm
    } else {
      // handle all other cases
    }
  }
)

Open in new window

becomes a promise
swal({title: 'Are you sure?', showCancelButton: true}).then(result => {
  if (result.value) {
    // handle Confirm button click
    // result.value will contain `true` or the input value
  } else {
    // handle dismissals
    // result.dismiss can be 'cancel', 'overlay', 'esc' or 'timer'
  }
})

Open in new window


My question is which version are you using?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Crystal RouseTask LeadAuthor Commented:
We have probably one of the very first versions. We've never upgraded it.
0
Crystal RouseTask LeadAuthor Commented:
I fixed it myself.  Simply replaced: }.bind(this));
with });
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Crystal RouseTask LeadAuthor Commented:
I fixed it myself.  Simply replaced: }.bind(this));
 with });
0
Crystal RouseTask LeadAuthor Commented:
I fixed it myself.  Simply replaced: }.bind(this));
 with });
1
Varun WaliaPHP developerCommented:
sweetAlert is used in older versions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.