I have a link on my website which opens a html content from a different webpage in a jquery ui dialog:
var $otherDialogContainer = $('#other-dialog');
$('a.link').click(function() {
$otherDialogContainer.load('/controller/action', function() {
$otherDialogContainer.dialog({
title: 'Hello',
width: 600,
height: 400,
开发者_如何学运维 position: 'middle',
resizable: false
});
});
return false;
});
In the html that's opened in the dialog there is a button which closes the dialog like this:
$('.closeDialog').click(function() {
window.parent.$(".ui-dialog").remove();
});
The problem is, I cannot reopen the dialog after I close it with that button. If I close the dialog by clicking the 'x' icon in the top right corner, I can reopen it without a problem.
.remove() removes the dialog from the DOM so there is no longer a dialog to open :)
You should use
$otherDialogContainer.dialog('close');
Hope this helps!
精彩评论