6

来源:互联网 发布:medline数据库中文 编辑:程序博客网 时间:2024/05/16 19:01
c) 直接render到dom子节点中,未显式销毁
Ext.ns("Ext.ux");  
Ext.ux.MyComponent = Ext.extend(Ext.BoxComponent, {  
    tpl : "{text}:<div class='combo'></div>",  
    afterRender : function(){  
        Ext.ux.MyComponent.superclass.afterRender.apply(this, arguments);  
        this.setCombo();  
    },  
    update : function(){  
        Ext.ux.MyComponent.superclass.update.apply(this, arguments);  
        this.setCombo();  
    },  
    setCombo : function(){  
        // this.combo每次更新时都创建了新实例,没有销毁旧的,组件销毁时也未销毁它。  
        this.combo = new Ext.form.ComboBox({  
            store : new Ext.data.ArrayStore({  
                fields: ['id', 'mode'],  
                data :  [  
                    ['1', 'mode1'],  
                    ['2', 'mode2']  
                 ]  
            }),  
            valueField : "id",  
            displayField:'mode',  
            mode: 'local',  
            triggerAction: 'all',  
            emptyText:'请选择模式',  
            selectOnFocus:true 
        });  
        this.combo.render(this.el.child("div.combo"));  
    }  
});  
 
// 创建&销毁  
var test = new Ext.ux.MyComponent({  
    data : {  
        text : "请选择模式" 
    },  
    renderTo : Ext.getBody()  
});  
 
test.destroy();  
test = null; 
原创粉丝点击