如何在 extjs 中关闭父容器
How to close parent container in extjs
我试图用 this.up().close()
在 extjs 中关闭父 window,但是 this.$className 是未定义的。
我正在寻找不使用 Ext.getCmp.
的解决方案
你的范围是错误的。你给你的元素应用程序的范围,这就是为什么 this.up() 不起作用的原因。如果删除 scope: this
,您应该可以使用 this.up()
获取父容器。
我用一个工作示例对你的煎茶做了一个分支 fiddle:
Sencha fiddle example
不确定你想隐藏什么,无论如何:
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.Container', {
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
title: 'my Panel',
html: "Some text.",
width: 350
}, {
xtype: 'box',
html: '<a href="#" class="link-forgot-password"> Close window</a>',
listeners: {
render: function () {
this.getEl().on('click', function () {
//this.up('container').hide(); // Hide wrapper container
this.previousSibling().hide(); // Hide previous Panel
}, this);
}
}
}]
});
}
});
我试图用 this.up().close()
在 extjs 中关闭父 window,但是 this.$className 是未定义的。
我正在寻找不使用 Ext.getCmp.
你的范围是错误的。你给你的元素应用程序的范围,这就是为什么 this.up() 不起作用的原因。如果删除 scope: this
,您应该可以使用 this.up()
获取父容器。
我用一个工作示例对你的煎茶做了一个分支 fiddle: Sencha fiddle example
不确定你想隐藏什么,无论如何:
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.Container', {
renderTo: Ext.getBody(),
items: [{
xtype: 'panel',
title: 'my Panel',
html: "Some text.",
width: 350
}, {
xtype: 'box',
html: '<a href="#" class="link-forgot-password"> Close window</a>',
listeners: {
render: function () {
this.getEl().on('click', function () {
//this.up('container').hide(); // Hide wrapper container
this.previousSibling().hide(); // Hide previous Panel
}, this);
}
}
}]
});
}
});