Reputation: 546
I use a simple JavaScript confirm function that is used by all pages in my Asp.net project and I want to replace it with jQuery confirm dialog. I use Apprise jQuery confirm dialog library. But the asynchronous work of jQuery confirm dialog causes problem. Let me give you some code examples of my project..
This is my old JavaScript confirm function
function confirmForOperation(message) {
if (confirm(message) == true)
return true;
else
return false;
}
This is my new asynchronous jQuery confirm dialog function
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;
}
});
}
You may offer me to use the below function as
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;
}
});
}
But callBack mechanism does not work for me because one of the area(code) I use this confirm dialog function is as below:
<asp:Button ID="btnDelete" runat="server" CausesValidation="false" CommandName="Delete"
Text="<%$ Resources:BTNResource, BUTTON_DELETE_LABEL %>" OnClientClick="return confirmForOperation();" />
Any idea ?
Upvotes: 4
Views: 9746
Reputation: 991
I was looking this up too, the answer is no. See this excellent explanation here:
Change the asynchronous jQuery Dialog to be synchronous?
Upvotes: 1