2011-05-17 67 views
0

親愛Friends.i我在關閉我的window.I調用Ajax調用這樣ExtJS的窗口等待

function callPreviewWindow(){ 
    $.ajax({ 
    type : "GET", 
    url : "/ajax/eform/preview.do", 
    cache : false, 
    dataType : "text/html", 
    timeout: 40000, 
       beforeSend : function() { 
     showWaitingDialog("Please wait..."); 
    }, 

    error: function (xhr, err) 
    { 
     resolveAjaxError(xhr, err); 
    }, 
    success : function(data) { 
     showPreviewWindow(data); 

    } 
});  

}

面臨的一個問題對話閉幕問題,但是這個AJAX調用執行花費更多的時間,以便增加超時到40000.它工作正常,並顯示以下窗口。

function showPreviewWindow(htmlData){ 
var previewWindow = new Ext.Window({ 
     title: "E-Form View", 
     width:650, 
     id:'previewWindow', 
     autoHeight: true, 
     html: htmlData, 
     modal: true, 
     y: 150, 
     listeners: { 
     beforeclose: function() { 
      searchVisible = false;      
      } 
     }, 
     buttons: [ 
       { 
        text: 'Close', handler: function() { 
         previewWindow.close();            
        } 
       } 
       ] 
}); 

previewWindow.show(this);    

}

但問題是,當點擊關閉按鈕,我能關閉該窗口。但是showWaitingDialog(我在ajax調用函數中發送事件之前調用的)沒有關閉。

請幫我關閉這也關閉按鈕單擊。

在此先感謝。 Sathya

回答

0

它看起來像對話框和窗口沒有鏈接。因此,在您的關閉處理程序中,您還需要關閉對話框以及窗口。你如何做到這一點將取決於showWaitingDialog()函數在做什麼 - 但是你可能需要存儲一個對該方法中創建的對話框的引用,然後在你的關閉處理程序中調用對話框上的方法(如對話框.close())也可以解散它。這可能需要你修改showWaitingDialog()方法返回到對話框的引用:

function showWaitingDialog() { 
    // dialog is created as normal 

    // add something like this 
    return dialog; 
} 

然後修改您的對話框啓動和關閉處理程序使用存儲對話框:

// Dialog reference will be stored here  
var dialog; 

function callPreviewWindow(){ 
    $.ajax({ 
     type : "GET", 
     url : "/ajax/eform/preview.do", 
     cache : false, 
     dataType : "text/html", 
     timeout: 40000, 
     beforeSend : function() { 
      // Store reference 
      dialog = showWaitingDialog("Please wait..."); 
     }, 
     error: function (xhr, err) { 
      resolveAjaxError(xhr, err); 
     }, 
     success : function(data) { 
      showPreviewWindow(data); 
     } 
    }); 
} 

function showPreviewWindow(htmlData){ 
    var previewWindow = new Ext.Window({ 
     title: "E-Form View", 
     width:650, 
     id:'previewWindow', 
     autoHeight: true, 
     html: htmlData, 
     modal: true, 
     y: 150, 
     listeners: { 
     beforeclose: function() { 
      searchVisible = false;      
      } 
     }, 
     buttons: [{ 
      text: 'Close', handler: function() { 
       previewWindow.close(); 
       dialog.close();            
      } 
     }] 
    }); 

    previewWindow.show(this);  
}