我有一个带有iFrame的jQuery模态对话框,其中显示了一些内容。当用户在iFrame中选择选项时,我会进行Ajax调用,然后我想关闭我的对话框,但是对话框没有关闭。
在我的父表单上,我有一个div标签:
在我的 iFrame 中,我有以下内容:
在我的buildSuccess函数中,我成功地将对话框的颜色改为了红色。但是,关闭函数无法关闭对话框。从目前为止我看到的大多数示例来看,这段代码应该没有问题,所以我很困惑。
在我的父表单上,我有一个div标签:
div id="structureDialog" title="Add Structure"
当用户点击父元素上的某个元素时,我会打开我的对话框:
// bind an onclick event onto tiles to display the modal dialogue window
$(".stationTile").bind('click', function () {
var src = "<iframe src="myurl" />";
var locationID = 1;
$("#structureDialog").attr("locationID", locationID);
$("#structureDialog").html(src); //iframe
$("#structureDialog").dialog({
modal: true,
});
});
在我的 iFrame 中,我有以下内容:
$(".userOption").bind('click', function () {
$.ajax({
async: false,
type: "POST",
url: "/NewStructure.aspx/Build",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: buildSuccess
});
});
function buildSuccess(res, dest) {
$("body", window.parent.document).attr("style", "background-color:yellow;");
$("#structureDialog", window.parent.document).attr("style", "background-color:red;");
$("#structureDialog", window.parent.document).dialog('close');
}
在我的buildSuccess函数中,我成功地将对话框的颜色改为了红色。但是,关闭函数无法关闭对话框。从目前为止我看到的大多数示例来看,这段代码应该没有问题,所以我很困惑。