We help IT Professionals succeed at work.

Using isConfirm with a SweetAlert

Crystal Rouse
on
381 Views
1 Endorsement
Last Modified: 2018-12-14
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

Comment
Watch Question

Developer
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Crystal RouseTask Lead

Author

Commented:
We have probably one of the very first versions. We've never upgraded it.
Crystal RouseTask Lead

Author

Commented:
I fixed it myself.  Simply replaced: }.bind(this));
with });
Crystal RouseTask Lead

Author

Commented:
I fixed it myself.  Simply replaced: }.bind(this));
 with });
Crystal RouseTask Lead

Author

Commented:
I fixed it myself.  Simply replaced: }.bind(this));
 with });
Varun WaliaPHP developer

Commented:
sweetAlert is used in older versions.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions