zoukankan      html  css  js  c++  java
  • sweetalert 1.0多次回调函数bug

    一个删除功能,原来的实现方式(注释部分)有多次的回调,会出现第二个swal窗口不显示,回调函数体不执行的情况。后来的解决方式是使用bootstrap的modal模态框,删除成功后显示模态框,模态框关闭后执行刷新,曲线救国啊。
    $('button.btn.btn-danger.btn-sm.delOneType').click(function () { var dTypeId=$(this).attr('key'); swal({ title:"", text:"确定删除吗?", type:"warning", showCancelButton:"true", showConfirmButton:"true", confirmButtonText:"确定", cancelButtonText:"取消", animation:"slide-from-top" }, function(){ $.ajax({ url: url+"/delDefinedTypeBydTypeId", //请求的url地址 dataType: "json", //返回格式为json async: true, //请求是否异步,默认为异步,这也是ajax重要特性 data: {dTypeId: dTypeId}, //参数值 type: "GET", //请求方式 success: function(data, textStatus) { if(data.status == 1){ /*swal({ title:"", text:"删除档案类型成功", type:"success", showConfirmButton:"true", confirmButtonText:"关闭", animation:"slide-from-top" }, function() { window.location.reload(); });*/ $('#delSuccModal').modal({backdrop: 'static', keyboard: false}); //初始化并启动 } else { swal({ title:"", text:data.msg, type:"error", showConfirmButton:"true", confirmButtonText:"关闭", animation:"slide-from-top" }); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { console.log('请求发生错误:' + textStatus); } }); }); });
  • 相关阅读:
    I/O流
    课堂测试
    1021课堂内容
    课堂jsp
    课堂动手动脑
    从小工到专家读后感
    课堂测试2
    回文课堂测试
    一周进度条博客
    Echart图表
  • 原文地址:https://www.cnblogs.com/alanleung/p/6740816.html
Copyright © 2011-2022 走看看