Possible Duplicate:
How to create a custom “confirm” & pause js execution until user clicks button?
I am trying to implement custom confirmation box in jquery,but my Custom ConfirmationBox does not wait for user's response and further script gets executed. Can someone help me in implementing synchronous custom confirmation box.
my code goes like
<a type="button" name="/ActionName/ViewName/@item.RawDocumentID" href="../ActionName/ViewName/@item.RawDocumentID" id="replaceDoc" class="openDialog">Replace</a>open a popup
$('.replaceDoc').click(function (e)
{
if (condition)
{
MyConfirm(msg, function (e)//This function is used create customconfirm
{
status = true;
}
},
function ()
{
status = false;
e.stopImmediatePropagation();
e.preventDefault();
},
'MyConfirm');
});
function MyConfirm(temp, okFunc, cancelFunc, dialogTitle)
{
$("<div class='carbon-alert'></div>")
.attr("id", 'CarbonConfirm')
.dialog({
resizable: false,
height: 140,
modal: true,
title: dialogTitle,
open: function ()
{
$(this).html(temp);
},
buttons: {
OK: function ()
{
if (typeof (okFunc) == 'function') { setTimeout(okFunc, 50); }
$('#MyConfirm').remove();
},
Cancel: function ()
{
if (typeof (cancelFunc) == 'function') { setTimeout(cancelFunc, 50); }
$('#MyConfirm').remove();
}
}
});
}
Now the problem is my confirmationbox comes, but over it popup gets displayed, I want my popup to come only when I click Ok.