t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.39k stars 2.84k forks source link

How to handle confirm button action? #872

Closed brkbzdg94 closed 5 years ago

brkbzdg94 commented 5 years ago

I want OK button click then after, return a value. how can i do this?

function mySwalAlert(atitle, atext, atype) { var rtn = null; swal({ title: atitle, text: atext, type: atype, showCancelButton: true, confirmButtonColor: "#EF5350", confirmButtonText: "Evet!", cancelButtonText: "Hayır", closeOnConfirm: false, closeOnCancel: false }, function (isConfirm) { if (isConfirm) { rtn = 1; } else { rtn = 0; } }); if (rtn == 1) return true; else return false; }

But always return false. Because firstly function(isConfirm){ } run

t4t5 commented 5 years ago

It looks like you're using an old version of the library. Take a look at the upgrade guide