Hello.

On the site everywhere in js-scripts on some functions worth checking

function name(){ if (!confirm("Удалить?")) { return; } ......выполнение.... } 

I started using sweetalert for bootstrap, but I realized that it would take a very long time to remove the confirm confirm in all files. I decided to try to cheat - just override the function

 function confirm(text){ swal({ title: text, type: "warning", showCancelButton: true, cancelButtonClass: 'btn', cancelButtonText: 'Нет', confirmButtonClass: "btn-danger", confirmButtonText: "Да", closeOnConfirm: false }, function (isConfirm) { if (isConfirm) { //тут подтверждение } else { //тут отказ } }); } 

Tell me how to make this function return true or false, so that the test works correctly everywhere?

  • one
    No way (10 characters needed ...) - Igor
  • please explain, do not understand - Sarkis Allahverdian
  • No, well, seriously, do not do it, and then someone in the future will be very sorry (maybe you) - Duck Learns to Take Cover
  • one
    @SarkisAllahverdian You are changing a call to a blocking function to a call to a non-blocking function. Substitute confirm it will not work. - Igor

0