javascript - Sweet alert timer - done function -
i have been playing little sweetalert plugin: sweet alert
i wanted make delete button, user gets prompted before actual delete. when user presses "delete" again, says "done" , user has click "ok" again prompt go away good.
sweetalert has timer function, can auto close last "done" prompt after few seconds or so, works fine. have feature, can implement function run when user clicks "ok" on "done" prompt. problem is, function not run, if prompt auto closes after timer done.
any ideas how can done?
with timer , function not being run:
swal({ title: "deleted!", text: "your row has been deleted.", type: "success", timer: 3000 }, function () { location.reload(true); tr.hide(); });
without timer, working function (on click "ok" button):
swal("deleted!", "your row has been deleted.", "success"), function () { location.reload(); tr.hide(); };
explanation
i think have take swal
apart function. mean swal
displayed, function runs on background , modal automatically closes.
javascript/jquery:
swal({ title: "deleted!", text: "your row has been deleted.", type: "success", timer: 3000 }); function () { location.reload(true); tr.hide(); };
your code example of sweetalert:
swal({ title: "are sure?", text: "you not able recover imaginary file!", type: "warning", showcancelbutton: true, confirmbuttoncolor: "#dd6b55", confirmbuttontext: "yes, delete it!", cancelbuttontext: "no, cancel plx!", closeonconfirm: false, closeoncancel: false }, function (isconfirm) { if (isconfirm) { swal({ title: "deleted!", text: "your row has been deleted.", type: "success", timer: 3000 }); function () { location.reload(true); tr.hide(); }; } else { swal("cancelled", "your imaginary file safe :)", "error"); } });
Comments
Post a Comment