I am running into this same issue. Basically I have a page that does
some data manipulation that I want the user to confirm on close. This
page is hosted in a iframe that is displayed in a jquery dialog. When
on beforeclose is called, I verify the result and if the user has not
acknowledged it on the page I open a confirm dialog to give them an
opportunity to halt the close and confirm the data (think, changes
have not been saved, do you really want to exit). When the 'x' is
clicked on the dialog, the beforeclose executes correctly. However,
when the dialog completes it's close before the confirm is displayed,
and prior to any return from the callback.
If I get a chance I will try to replicate in a simpler example that I
can post somewhere.
I cannot post all the code here but below is the code that handles the
dialog.
default.htm - home page hosts div and js for pop-up:
//open pop-up
Manager.openModal = function(innerHtml, title, cssClass, onOK,
onClose, width, height, onSuccess, onCloseEvent, onBeforeCloseEvent) {
$("#modalDiv").html("");
$("#modalDiv").html(innerHtml);
$("#modalDiv").dialog({ draggable: true, resizable:
false, modal:
true, zIndex: 4999, title: title, position: 'center' });
if (height == null) {
height = $(window).height() -
Math.round($(window).height() * .2);
}
if (width == null) {
width = $(window).width() -
Math.round($(window).width() * .1);
}
if (cssClass) {
$("modalDiv").dialog('option', 'dialogClass',
cssClass);
}
if (onOK != null && onClose != null) {
$("#modalDiv").dialog('option', 'buttons', {
"Close": onClose,
"Ok": onOK });
}
else if (onOK != null) {
$("#modalDiv").dialog('option', 'buttons', {
"Ok": onOK });
}
else if (onClose != null) {
$("#modalDiv").dialog('option', 'buttons', {
"Close": onClose });
}
if (height != null) {
$("#modalDiv").dialog('option', 'height',
height);
$("#modalDiv").dialog('option', 'position',
'center');
}
if (width != null) {
$("#modalDiv").dialog('option', 'width', width);
$("#modalDiv").dialog('option', 'position',
'center');
}
if (onSuccess != null) {
Manager.onModalSuccess = onSuccess;
}
$("#modalDiv").dialog("open");
if (onCloseEvent) {
$("#modalDiv").bind('dialogclose',
onCloseEvent);
}
if (onBeforeCloseEvent) {
$("#modalDiv").bind('dialogbeforeclose',
onBeforeCloseEvent);
}
}
ListManager.htm - generates the html for the pop-up
//Code for instance calling openModal using beforeclose (called from
page hosted in frame of default.htm).
ListManager.showDetail = function(uuid) {
var width = CRManager.getWindowWidth() - Math.round
(CRManager.getWindowWidth() * .2);
var height = CRManager.getWindowHeight() - Math.round
(CRManager.getWindowHeight() * .1);
var iframeHgt = height - 40;
ListManager.SelectedResult = uuid;
var html = "<iframe frameborder='0' width='100%'
height='" +
iframeHgt + "' src=http://" + top.location.host + "/iframe_page.htm?
uuid=" + uuid + "></iframe>";
parent.Manager.openModal(html, "Detail", null, null,
null, width,
height, null, ListManager.acknowledgeConfirm);
}
//Callback for beforeclose
ListManager.acknowledgeConfirm = function(event, ui) {
if (CRManager.ActiveRole == CRManager.ROLE_SENDER ||
CRManager.ActiveRole == CRManager.ROLE_RECEIVER) {
var resultAck = true;
$(CRManager.ListResults).each(function(i,
result) {
if (result.ResultUuid ==
ListManager.SelectedResult) {
if (result.AcknowledgementTime
== null) {
resultAck = false;
}
}
});
if (resultAck == false) {
var confirmResult = confirm("Please
acknowledge the result.");
if (confirmResult) {
return false;
}
else {
return true;
}
}
}
else {
return true;
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---