1
我想打開幾個對話框(第一個對話框打開併發出ajax請求,如果成功顯示第二個對話框)問題是,第一個對話框打開正確在屏幕中間,但是當我關閉它時,第二個對話框在頁面頂部打開而不在中間。鏈接jquery對話框:第二個對話框不在中心
我有所有jquery ui依賴關係,因爲我使用了構建頁面並選擇了一切。
該項目很大,所以我創建了一些接近我正在使用的代碼。
首先,打開對話框
$(".btblock").click(function (event) {
event.preventDefault();
var btn = $(this);
var id= btn.attr('id');
$("#divDialog1").dialog({
dialogClass: 'notitle',
modal: true,
zIndex: 10002,
resizable: false,
closeOnEscape: false,
open: function (event, ui) {
$(".ui-dialog-titlebar-close").hide();
},
buttons: {
"Ok": function() {
//Here I call another function which is an ajax call.
//when the ajax call is completed (success or not) I call
//another function which creates the second dialog with results
$(this).dialog("close");
}
}
});
});
//Function called after ajax call. creats a result dialog
//This Dialog doesn't show in the middle of the screen
function customAlertMessage(title, message) {
var div = '<div style="text-align:center;" title="' + title + '">' + message + '</div>'
$(div).dialog({
resizable: false,
dialogClass: 'notitle',
modal: true,
buttons: {
"Ok": function() {
$(this).dialog("close");
}
}
});
}
也許你可以發佈一些代碼? – mituw16
使用一些示例代碼進行編輯。 – jpgrassi