2014-12-04 51 views
2

這樣Ext.window.MessageBox拖動虛假,錯誤調用隱藏方法

var msgBox = Ext.create('Ext.window.MessageBox',{draggable: false}); 

-actually拖動虛假通過倍率時Ext.window.Window設置創建MessageBox的實例後,我像這樣放置它可以更容易地重現。

- 我更喜歡singleton語法,但在我正在處理的代碼中已經創建了大量像這樣的實例。

msgBox.alert("I am a bug, try to close me to reproduce"); 

試圖關閉這個MessabeBox調用隱藏方法:

hide: function() { 
     var me = this; 
     me.dd.endDrag(); 
     me.progressBar.reset(); 
     me.removeCls(me.cfg.cls); 
     me.callParent(arguments); 
    }, 

這引發以下錯誤:

Cannot read property 'endDrag' of undefined

我缺少的東西,或這是一個錯誤?

UPDATE:

我使用ExtJS的4.1.1(但也發生在ExtJS的4.2.1(固定在4.2.2))

任何意見或建議?

+1

嗯。你確定你正在使用股票Ext.window.MessageBox?我正在查看源代碼,它與您在此發佈的內容完全不同。 – 2014-12-06 01:11:06

+0

確實這是固定的4.2.2,謝謝你的澄清。這是4.2.1之前的一個問題 – 2014-12-06 05:48:50

回答

1

爲了避免這種錯誤,我在MessageBox類中重寫隱藏方法:

 Ext.define('Ext.window.MessageBox', { 
      override: 'Ext.window.MessageBox', 
      hide : function() { 
       /** 
       * this is the default implementation of hide in minus MessageBox the commented line 
       * */ 
       var me = this; 
       //me.dd.endDrag(); 
       me.progressBar.reset(); 
       me.removeCls(me.cfg.cls); 
       /** 
       * this is the implementation of hide in Ext.Component 
       * avoided callParent() because that would have called the overridden hide method 
       */ 
       me.showOnParentShow = false; 
       if (!(me.rendered && !me.isVisible()) && me.fireEvent('beforehide', me) !== false) { 
        me.hidden = true; 
        if (me.rendered) { 
         me.onHide.apply(me, arguments); 
        } 
       } 
       return me; 
      } 
     }); 

更新,這是原來的覆蓋

Ext.window.Window.override({ 
    initComponent: function() { 
     this.draggable = false; 
     this.resizable = false; 
     this.callParent(); 
    } 
}); 

我打開來避免這個建議覆蓋。謝謝。

相關問題