Tag: sweetalert

sweetAlert preventDefault并返回true

我试过了sweeAlert插件,它运行得很好,但是在确认后我无法弄清楚如何做默认的东西。 $(document).ready(function () { function handleDelete(e){ e.preventDefault(); swal({ title: “Are you sure?”, text: “You will not be able to recover the delaer again!”, type: “warning”, showCancelButton: true, confirmButtonColor: “#DD6B55”, confirmButtonText: “Yes, delete!”, closeOnConfirm: false }, function (isConfirm) { if (isConfirm) { return true; } }); }; }); 和按钮 id_dealers}” class=”delete” onclick”handleDelete(event);”>  //https://stackoverflow.com/questions/30418718/sweetalert-preventdefault-and-return-true/{plink delete! $row->id_dealers} Nette […]

甜蜜警报计时器 – 完成function

我一直在玩SweetAlert插件: Sweet alert 我想创建一个删除按钮,在实际删除之前用户会收到提示。 当用户再次按下“删除”时,则表示“已完成”并且用户必须再次单击“确定”才能提示离开。 SweetAlert具有计时器function,因此您可以在几秒钟左右后自动关闭最后一个“完成”提示,这样就可以了。 它们还有一个function,您可以在用户在“完成”提示下单击“确定”时实现要运行的function。 问题是,如果在计时器完成后提示自动关闭,则不运行该function。 有什么想法可以做到这一点? 没有运行Timer和function: swal({ title: “Deleted!”, text: “Your row has been deleted.”, type: “success”, timer: 3000 }, function () { location.reload(true); tr.hide(); }); 没有计时器,但具有工作function(点击“确定”按钮): swal(“Deleted!”, “Your row has been deleted.”, “success”), function () { location.reload(); tr.hide(); };

在将Canvas HTML图像下载到PNG之前,Sweet Alert弹出提示

在我的Canvas绘图应用程序中,我有一个下载到png按钮,我想这样做,所以当用户在我的甜蜜警报弹出提示点击“是保存它”时,只下载canvas上的图像。 现在它仍在自动下载。 谢谢您的帮助。 (如果有人有更好的方式通过Javascript下载也有帮助,它正在下载png但是它已损坏我无法打开它) $(‘#download’).click(function(){ swal({ title: “Are you finished your creation?”, text: “click yes to save”, type: “warning”, showCancelButton: true, confirmButtonColor: “#f8c1D9”, confirmButtonText: “Yes, save it!”, closeOnConfirm: true }, function (isConfirm) { if (isConfirm) { swal(“Saving!”); var base64 = document.getElementById(“canvas”) .toDataURL(“image/png”) .replace(/^data:image\/[^;]/, ‘data:application/octet-stream’); document.getElementById(“download-png”).href = base64 } else { } return false; }); }); […]

SweetAlert下拉列表动态添加列表中的项目

我目前正在使用sweetalert2从对话框中捕获用户的输入。 我想在链接队列对话框中使用下拉列表,但我似乎找不到在下拉列表中动态添加项目的方法。 假设我想从JSON格式检索数据并放在下拉列表中,有没有办法做到这一点? function userInput() { swal.setDefaults( { showLoaderOnConfirm: true, confirmButtonText: ‘Next →’, showCancelButton: true, animation: true, progressSteps: [‘1’, ‘2’, ‘3’] } ); var steps = [ { text: ‘Select an author to analyze the commit’, input: ‘select’, inputOptions: { ‘SRB’: ‘Serbia’, // How do I dynamically set value? ‘UKR’: ‘Ukraine’, ‘HRV’: ‘Croatia’ } }, […]

甜蜜警报继续提交表格确认

我在提交表格时触发了这个甜蜜的事情。 $(“.swa-confirm”).on(“submit”, function(e) { e.preventDefault(); swal({ title: $(this).data(“swa-title”), text: $(this).data(“swa-text”), type: “warning”, showCancelButton: true, confirmButtonColor: “#cc3f44”, confirmButtonText: $(this).data(“swa-btn-txt”), closeOnConfirm: false, html: false }, function() { } ); }); 但点击确认我希望它继续提交表格… 我想到了不好的想法,例如: var confirmed = false; $(“.swa-confirm”).on(“submit”, function(e) { var $this = $(this); if (!confirmed) { e.preventDefault(); swal({ title: $(this).data(“swa-title”), text: $(this).data(“swa-text”), type: “warning”, showCancelButton: true, confirmButtonColor: […]

sweetalert 2上有2个以上的按钮

我有一个带有2个按钮的sweetalert,但我想再添一个按钮。 例如,截至目前,我有,是的,我想再添加一个按钮。 请帮忙 $(“#close_account”).on(“click”, function(e) { e.preventDefault(); swal({ title: “Are you sure?”, text: “You will not be able to open your account!”, type: “warning”, showCancelButton: true, confirmButtonColor: “#DD6B55”, confirmButtonText: “Yes, close my account!”, closeOnConfirm: false }, function(){ window.location.href=”” }); }); 提前致谢:)

未使用(承诺)取消使用SweetAlert2

如何在使用promises时正确转义取消按钮而不会抛出错误? 我的代码会抛出一个带有必填复选框的警报确认。 代码应该对用户执行,但它会在控制台窗口中引发错误: 未被捕(承诺)取消 //validation logic all passes…Now proceed to… else { //determine and parse Discounts var myLookup = document.getElementsByName(“myLookup”)[0].value; $.post( “findthem.php”, {myLookup: myLookup }) .done(function(json_data){ var theResponse1 = $.parseJSON(json_data); myDiscountRate = theResponse1[‘ourDiscountFound’]; }).then( function(callback){ priceRate = priceRate * (1 – (.01 * myDiscountRate)); newRate = priceRate.toFixed(2); } swal({ title: “Confirm”, input: ‘checkbox’, inputValue: 0, […]

如何使用甜蜜警报添加Ajax调用

我的Ajax方法看起来像这样 $.post(url,{ ajax_call:”putDonation”, addresse:addresse, phone:phone, email:email, name:name, amount:amount, amountinwords:amountinwords }).done(function(data){ console.log(data); var arr = []; try { var str = “”; //convert to json string arr = $.parseJSON(data); //convert to javascript array $.each(arr,function(key,value){ str +=””+value+””; }); alert(str); $(“.alert-danger”).show(); $(“#error”).html(str); } catch (e) { swal(“Jay Gayatri !”, ‘Donation Sucessful’, “success”) $(“#donation”)[0].reset(); } }) 我想展示一个像这样的甜蜜警报警告弹出窗口 swal({ title: […]