我有一个屏幕,其中formBase包含所有动态创建的UI控件。我正在使用卡片布局并在视图之间切换。现在恰巧我每次卡片切换时都必须执行formBase(我的意思是每当我的屏幕出现时)。在sencha触摸卡切换时刷新屏幕
我已经使用beforeshow侦听器来实现这一点。但它不工作。以下是我的代码。
var formBase = new Ext.form.FormPanel({
scroll: 'vertical',
ui: 'round',
items: [fieldSet, {
xtype : 'fieldset',
items : [ item1, item2, item3]
]
}],
listeners: {
beforerender: function(ele) {
console.log(" Screen before render");
initScreenComps()
},
beforeshow: function(ele) {
console.log(" screen before show");
}
}
});
编辑:1
我有一个viewport.js文件,在那里我有揭示方法来改变视窗。这里是Viewport.js的下面的代码。它仍然没有效果。请提出建议。
MyApp.views.Viewport = Ext.extend(Ext.Panel, {
fullscreen: true,
layout: 'card',
initComponent: function() {
Ext.apply(this, {
items: [
{ xtype: 'MyApp.views.view1', id: 'view1' },
{ xtype: 'MyApp.views.view2', id: 'view2' },
{ xtype: 'MyApp.views.view3', id: 'view3' },
{ xtype: 'MyApp.views.view4', id: 'view4' },
{ xtype: 'MyApp.views.view5', id: 'view5' }
],
listeners:{
beforecardswitch:function(newCard, oldCard, index, animated){
//do something...
console.log(" Card switched" + " New " + newCard + " OLD : " + oldCard + " index + " index);
}
}
}
);
MyApp.views.Viewport.superclass.initComponent.apply(this, arguments);
},
// used for changing view port of application
reveal: function(target) {
this.setActiveItem(MyApp.views[target],{ type: 'slide', direction: 'right' }
);
}
});
现在我从控制器调用view2上的按钮单击事件。
MyApp.views.viewport.reveal('view2');
beforeactivate侦听器无法正常工作..它没有影响 –
@Swar ..非常感谢.. beforeactivate工作时,我用内部Ext.apply .. –