delete window[this.tipFnName]

越来越发现Ext的源码中很多地方对数据的有效性检验的不够好,甚至很多地方都没有检验便对其进行操作,例如Ext obj.ucountry is null错误。
这次遇到的错误是发生在Ext.chart.Chart组件,当在TabPanel的一个子Panel中使用了该组件并关闭当前的子Panel时,在火狐下不会有任何问题,而IE下则会报错,错误停留在源码中的delete window[this.tipFnName]这句上。
这个错误发生在销毁组件的方法中,源码如下:

onDestroy: function(){
    Ext.chart.Chart.superclass.onDestroy.call(this);
    delete window[this.tipFnName];
}

可以看到这里对this.tipFnName没有做任何判断便执行了delete操作。那么解决方法就很简单了:

Ext.override(Ext.chart.Chart, { 
    onDestroy: function(){ 
      Ext.chart.Chart.superclass.onDestroy.call(this); 
      if(this.tipFnName){
        delete window[this.tipFnName];
      }
    } 
});

收藏与分享

转载原创文章请注明,转载自:Neeke[http://www.ineeke.com]

本文链接: http://www.ineeke.com/archives/delete-window-this-tipfnname/

2009年12月24日 | 归档于 ExtJS
标签:
  1. 2009年12月25日 00:05 | #1

    第一个浏览第一个留言,对你不错吧 n:-wx

  2. 2010年1月7日 18:05 | #3

    用GridPanel时出现’this.ds is undefined’,debug一下发现

    updateHeaderSortState : function(){
     var state = this.ds.getSortState();//这行报错了,ds是什么啊?
     if(!state){
     return;
     }
     if(!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)){
     this.grid.fireEvent('sortchange', this.grid, state);
     }
     this.sortState = state;
     var sortColumn = this.cm.findColumnIndex(state.field);
     if(sortColumn != -1){
     var sortDir = state.direction;
     this.updateSortIcon(sortColumn, sortDir);
     }
     },

发表评论

XHTML: 您可以使用这些标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
n:-zy n:-zan n:-xf n:-wx n:-tt n:-ts n:-sy n:-st n:-ss n:-sk n:-qd n:-pz n:-lh n:-kun n:-ku n:-hx n:-hd n:-gt n:-gg n:-bz