每次出现视图时,我都试图调用一个函数。但它只会被第一次调用,然后不会。是否有像 iOS 的 viewWillAppear 这样的事件函数。我正在使用“初始化”事件函数,它只被调用一次。请帮忙。
看法:
Ext.define('Abc.view.abc', {
extend: 'Ext.List',
xtype: 'runningList',
requires: ['Abc.store.InstancesStore','Ext.data.proxy.JsonP',],
config: {
title: 'Running',
id: 'instanceList',/*
itemTpl: '<div class="serached_listview">'+
'<div>{key} {key} </div>' +
'<div><b>{key}</b> </div>' +
'<div> {key}</div>' +
'</div>'
,*/
store: 'RunningInstanceStore',
listeners: [{
fn: 'initialize',
event: 'initialize'
}
]
}
});
控制器:
Ext.define("Abc.controller.InstancesController", {
extend: 'Ext.app.Controller',
requires: [ 'Ext.data.JsonP','Ext.device.Connection'],
config: {
refs: {
main: 'mainpanel',
Instances: '#instanceList',
ListView: 'runningList'
},
control: {
Instances: {
initialize: 'initializePanel',
activate:'initializePanel'
},
"runningInstancesList": {
disclose: 'listViewAccessoryTapped',
itemtap: 'listViewTapped'
}
}
},
listViewAccessoryTapped: function(view, index, item, e) {
if(Ext.device.Connection.isOnline())
console.log('Internet connection is available.');
else
console.log('Internet connection is not available.');
},
listViewTapped: function(view, index, item, e) {
},
initializePanel: function() {
console.log('Hi'); **////////////////Called only once...**
}
});