JQuery Alertify confirm dialog box not working properly

Satinder singh picture Satinder singh · Jul 13, 2013 · Viewed 8.9k times · Source

I am using Alertify JQuery Plugin, to display alert,confirm, dialog box.

Problem am facing for confirmation, it not work correctly on ok or cancel click

Sample JS FIDDLE

JS Code:

function myconfrm() {
 var falgset = true;
 alertify.confirm("Are you  sure to delete this record.", function (e) {
  if (e) {
          // user clicked "ok"
           falgset = false;
         }
    });
   alert(falgset);
   return falgset;
}

 $("#btn").live('click', function (event) {
                if (myconfrm()) {
                     // my ajax call 
           }
});

Answer

Satinder singh picture Satinder singh · Jul 17, 2013

This is how i solved
JS Fiddle DEMO

 $("#btn").live("click", function () {
     alertify.confirm("Are you sure you want to delete?", function (asc) {
         if (asc) {
             //ajax call for delete       
             alertify.success("Record is deleted.");

         } else {
             alertify.error("You've clicked cancel");
         }
     }, "Default Value");
 });