2013-08-03 70 views
0

中失敗我這樣定義http://jsfiddle.net/KABQD/
窗口下面是我的窗口EXTJS 4.1 - 隱藏窗口,並顯示它再次的MessageBox

Ext.define('MyWindow', { 
    extend: 'Ext.window.Window', 
    title: 'window', 
    width:200, 
    height:100, 

    modal:true, 
    closable:false, 
    tbar: [{  
     text:'hide', 
     handler:function(){ 
      this.up('window').hide(); 
     } 
    }] 
}); 

和一個按鈕。如果點擊按鈕我的窗口將被創建並首次顯示。如果再次點擊按鈕,則會顯示窗口。但是,當我使用Messagebox時,它會失敗。
如何解決謝謝


這是我的按鈕

Ext.create('Ext.Button', { 
    text: 'Click me', 
    visible: false, 
    renderTo: Ext.getBody(), 
    handler: function() { 
     var x = 0; 
     Ext.WindowManager.each(function(win) { 
      x = 1; 
      win.show(); 
     }); 
     if (x == 0){ 
      // if don't use MessageBox then will working 
      Ext.MessageBox.show({ 
       msg: 'wait...', 
       progressText: 'Loading...', 
       width:300, 
       wait:true, 
       waitConfig: {interval:200} 
      }); 
      //Ext.Ajax.request({ 
       //url : 'example.php' 
       //,success: function(response, opts) { 
        var a = new MyWindow(); 
        a.show(); 
        Ext.MessageBox.hide(); 
       //} 
      //}); 
     } 
    } 
}); 

回答

0

的問題是,WindowManager不能看到你的對象。你應該使用一個id實例化你的MyWindow對象,像這樣new MyWindow({id: 'NewWindow'});然後你可以在WindowManager中捕獲你的對象並且調用show()方法。

工作例如: http://jsfiddle.net/A92yN/3/

全碼:

Ext.define('MyWindow', { 
    extend: 'Ext.window.Window', 
    title: 'window', 
    width:200, 
    height:100, 

    modal:true, 
    closable:false, 
    tbar: [{  
     text:'hide', 
     handler:function(){ 
      this.up('window').hide(); 
     } 
    }] 
}); 
Ext.onReady(function() { 
     Ext.create('Ext.Button', { 
     text: 'Click me', 
     visible: false, 
     renderTo: Ext.getBody(), 
     handler: function() { 
      var x = 0; 
      Ext.WindowManager.each(function(win) { 
       x = 1; 
       var win = Ext.getCmp('NewWindow'); 
       win.show(); 
      }); 
      if (x == 0){ 
       // if don't use MessageBox then will working 
       Ext.MessageBox.show({ 
        msg: 'wait...', 
        progressText: 'Loading...', 
        width:300, 
        wait:true, 
        waitConfig: {interval:200} 
       }); 
       //Ext.Ajax.request({ 
        //url : 'example.php' 
        //,success: function(response, opts) { 
         var a = new MyWindow({id: 'NewWindow'}); 
         a.show(); 
         Ext.MessageBox.hide(); 
        //} 
       //}); 
      } 
     } 
    }); 
}); 
+0

我才明白這是爲什麼。 Extjs中的MessageBox和窗口都是窗口,並且都隱藏在我的問題中。但是如何知道如何捕捉並顯示我的窗戶?或如何關閉()MessageBox(不隱藏) – freestyle

+0

我使用destroy()我的MessageBox和一切工作感謝幫助:) – freestyle