我有一個屏幕,其中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 .. –