Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asynchronous 如何使用异步JQuery确认对话框作为同步对话框?_Asynchronous_Callback_Jquery Ui Dialog_Confirm - Fatal编程技术网

Asynchronous 如何使用异步JQuery确认对话框作为同步对话框?

Asynchronous 如何使用异步JQuery确认对话框作为同步对话框?,asynchronous,callback,jquery-ui-dialog,confirm,Asynchronous,Callback,Jquery Ui Dialog,Confirm,我使用了一个简单的JavaScript确认函数,Asp.net项目中的所有页面都使用该函数,我想用jQuery确认对话框替换它。 我使用ApprisejQuery确认对话框库。 但是jQuery确认对话框的异步工作会导致问题。 让我给你一些我的项目的代码示例 这是我以前的JavaScript确认函数 function confirmForOperation(message) { if (confirm(message) == true) return true;

我使用了一个简单的JavaScript确认函数,Asp.net项目中的所有页面都使用该函数,我想用jQuery确认对话框替换它。 我使用ApprisejQuery确认对话框库。 但是jQuery确认对话框的异步工作会导致问题。 让我给你一些我的项目的代码示例

这是我以前的JavaScript确认函数

function confirmForOperation(message) {
    if (confirm(message) == true)
        return true;
    else
        return false;
}
function confirmForOperation(message) {
    apprise(message, { 'verify': true, 'animate': true, 'textYes': 'Yes', 'textNo': 'No' },
    function (r) {
        if (r) {
            // User clicked YES..
            return true;
        }
        else {
            // User clicked NO..
            return false;
        }
    });
}
这是我新的异步jQuery确认对话框功能

function confirmForOperation(message) {
    if (confirm(message) == true)
        return true;
    else
        return false;
}
function confirmForOperation(message) {
    apprise(message, { 'verify': true, 'animate': true, 'textYes': 'Yes', 'textNo': 'No' },
    function (r) {
        if (r) {
            // User clicked YES..
            return true;
        }
        else {
            // User clicked NO..
            return false;
        }
    });
}
您可以让我使用以下功能作为

function confirmForOperation(message, callBack) {
    apprise(message, { 'verify': true, 'animate': true, 'textYes': 'Yes', 'textNo': 'No' },
    function (r) {
        if (r) {
            // User clicked YES..

            if ($.isFunction(callback)) {
                callback.apply();
            }
        }
        else {
            // User clicked NO..
            return false;
        }
    });
}
但回调机制对我不起作用,因为我使用此确认对话框函数的一个区域(代码)如下所示:

<asp:Button ID="btnDelete" runat="server" CausesValidation="false" CommandName="Delete"
Text="<%$ Resources:BTNResource, BUTTON_DELETE_LABEL %>" OnClientClick="return confirmForOperation();" />


有什么想法吗?

我也在查这个问题,答案是否定的。请看这里的精彩解释: