首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显示甜警报对话框时出错

显示甜警报对话框时出错
EN

Stack Overflow用户
提问于 2017-04-30 18:14:38
回答 1查看 794关注 0票数 2

我试图使用甜蜜警报库发出警报。我试图集成用于为删除项发出确认警报的代码,但当我单击要删除该项的按钮时,这些代码不起作用。没有显示对话框。

在集成Sweet之前编写代码:

代码语言:javascript
复制
$(".delete-link").click(function() {
    var id = $(this).attr("id");
    var del_id = id;
    var parent = $(this).parent("td").parent("tr");
    if (confirm('Sure to Delete ID no = ' + del_id)) {
        $.post('delete.php', { 'del_id': del_id }, function(data) {
            parent.fadeOut('slow');
        });
    }
    return false;
});

集成Sweet后的代码:

代码语言:javascript
复制
    $(".delete-link").click(function() {
        var id = $(this).attr("id");
        var del_id = id;
        var parent = $(this).parent("td").parent("tr");
    });

    swal({
            title: "Are you sure you want to delete?",
            text: "Sure to Delete ID no = " + del_id,
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes",
            closeOnConfirm: false
        },
        function() {
            $.post('delete.php', { 'del_id': del_id }, function(data) {
                parent.fadeOut('slow');
            });
        });
    return false;

});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-30 18:29:36

我认为您的代码中有语法错误。试试这个,看看它是否有效--我还没有在我这一边测试代码。如果不起作用,请告诉我

代码语言:javascript
复制
$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");

swal({
    title: "Are you sure you want to delete?",
    text: "Sure to Delete ID no = " + del_id,
    type: "warning",
    showCancelButton: true,
    confirmButtonColor: "#DD6B55",
    confirmButtonText: "Yes",
    cancelButtonText: "No",
    closeOnConfirm: true,
    closeOnCancel: true
}, function(isConfirm) {
    $.post('delete.php', {'del_id':del_id}, function(data) {
        parent.fadeOut('slow');
    });
});
return false;
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43709713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档