0

我正在尝试创建删除确认对话框。这是我的 jquery 对话框

$(function () {
    $("#del-dialog").dialog({
        autoOpen: false,
        width: 300,
        height: 100,
        modal: true,
        close: function (event, ui) {
            location.reload(false);
        },
        buttons: {
            'Delete': function () {
                $(this).dialog('close');
                // delete function goes here

             },
             'Cancel': function () {
                  $(this).dialog('close');
              }
        },
   });

   $(".icon-del").click(function (event) {
        event.preventDefault();
        $("#del-dialog").dialog("open");
    });
});

还有我的asp代码:

    l += "<a onclick='hello(";
                l += dr["cID"].ToString();
                l += ");'>";
                l += "</a>";

如何处理对话框按钮的删除功能?

4

1 回答 1

0
$(function () {
    $("#del-dialog").dialog({
        autoOpen: false,
        width: 300,
        height: 100,
        modal: true,
        close: function (event, ui) {
            location.reload(false);
        },
        buttons: {
            'Delete': function () {
                $(this).dialog('close');
                var target=$("#del-dialog").data("event").currentTarget
                $(target).data('isConfirming', true); 
                target.click();
                $(target).data('isConfirming', null);

             },
             'Cancel': function () {
                  $(this).dialog('close');
              }
        },
   });

   $(".icon-del").click(function (event) {
       if($(event.currentTarget).data('isConfirming')) return;
        event.preventDefault();
        $("#del-dialog").data("event",event);
        $("#del-dialog").dialog("open");
    });
});
于 2013-05-08T15:48:26.133 回答