对于选项卡面板中的每个选项卡,我都有一个位于固定位置的浮动面板。当我切换标签时,我需要将相应的浮动面板带到前面。但是,tabchange 事件仅在第一次触发。单击选项卡时,如何捕获此选项卡更改或其他类似事件?
Alexey,这是我的示例代码,其中包含更具体的问题:
Ext.onReady(function() {
panel1 = Ext.create('Ext.panel.Panel', {
title: 'title1', width: 800, height: 50,
listeners: { 'beforeshow': { fn: function() {
console.log("beforeshow on title1");
}, scope: this, single: true } }
});
panel2 = Ext.create('Ext.panel.Panel', {
title: 'title2', width: 800, height: 50,
listeners: { 'beforeshow': { fn: function() {
console.log("beforeshow on title2");
}, scope: this, single: true } }
});
panel3 = Ext.create('Ext.panel.Panel', {
title: 'title3', width: 800, height: 50,
listeners: { 'beforeshow': { fn: function() {
console.log("beforeshow on title3");
}, scope: this, single: true } }
});
var tabpanel = Ext.createWidget('tabpanel', {
renderTo: document.body,
activeTab: 0,
width: 800, height: 50, plain: true,
items: [panel1, panel2, panel3],
listeners: {
'tabchange': { fn: function() {
console.log("tabchange");
}, scope: this, single: true }
}
});
});
“tabchange”消息只打印一次。我真正想要的是每次单击选项卡时都显示“在...之前显示”消息。
雷欧,你就是男人!原来我的代码中的问题是“fn”。以下代码通过删除“fn”、“scope”和“single”完美运行。我不知道为什么。谁能解释一下?
Ext.onReady(function() {
panel1 = Ext.create('Ext.panel.Panel', {
title: 'title1', width: 800, height: 50,
listeners: { 'beforeshow': function() { console.log("beforeshow on title1"); } }
});
panel2 = Ext.create('Ext.panel.Panel', {
title: 'title2', width: 800, height: 50,
listeners: { 'beforeshow': function() { console.log("beforeshow on title2"); } }
});
panel3 = Ext.create('Ext.panel.Panel', {
title: 'title3', width: 800, height: 50,
listeners: { 'beforeshow': function() { console.log("beforeshow on title3"); } }
});
var tabpanel = Ext.createWidget('tabpanel', {
renderTo: document.body,
activeTab: 0,
width: 800,
height: 50,
plain: true,
items: [panel1, panel2, panel3],
listeners: {
'tabchange': function() {
console.log("tabchange");
}
}
});
});