我使用了一个简单的JavaScript确认函数,该函数在我的Asp.net项目的所有页面中使用,我想要用jQuery确认对话框来替换它。
我使用了Apprise jQuery确认对话框库。
但是,jQuery确认对话框的异步工作会导致问题。
让我给你展示一些我的项目代码示例...
这是我的旧JavaScript确认函数:
function confirmForOperation(message) {
if (confirm(message) == true)
return true;
else
return false;
}
这是我的新异步jQuery确认对话框函数
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();" />
有什么想法吗?