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;
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;
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- 6
- VC2005-应用程序正常初始化失败-0xc0150002
- 4
- Android点滴(五)
- 5
- 嵌入式系统文件系统比较 jffs2, yaffs, cramfs, romfs, ramdisk, ramfs/tmpfs
- 6
- word中从网页中复制的文字阴影如何去除?
- Objective-C 画图
- Linux学习笔记【2】——观看网页上的视频
- 全排列的递归算法
- Linux设备驱动程序学习(0)-Hello, world!模块
- Ubuntu操作基本快捷键
- 练手毛坯作品基于LINUX的"QQ闹眼子版本"(包括服务器与客户端<图形版与SHELL文字版>)
- android面试1