【发布时间】:2011-12-20 18:16:10
【问题描述】:
我正在调用一个 jquery 模式对话框,其中有一个保存按钮。保存按钮依次进行 ajax 调用,成功时会显示一个警告框“数据已保存!”并带有一个确定按钮。到目前为止一切正常。
现在“数据已保存”警告框关闭后,我也想自动关闭之前调用的模态对话框。有没有人做过类似的事情?
$( "#addFriendButton").click(function() {
$( "#addNewFriend" ).dialog({
title: 'Add a new friend.',
height:'auto',
width:'auto',
modal: true
});
});
//end addFriendButton
$( "#saveNewFriendButton").click(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/api/bb/apiV1/addFriend",
data: formToJSON(),
dataType: "json",
success: function(responseDTO){
displayOKAlertBox(responseDTO.responseMessage);
}
});
});
function displayOKAlertBox(message){
$("#alertMsg").html(message);
$( "#alertbox" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
}
【问题讨论】: