2
我是一個sencha新手,我試圖加載一個商店的參數取決於我在哪個視圖;在控制器中初始化列表
因此,我試圖捕捉我的列表的初始化事件,並加載該商店。
但初始化方法似乎不火
我控制器
Ext.define('FifaKings.controller.MainController', {
extend: 'Ext.app.Controller',
config: {
views: ['Main','InsertMatch','Kings'],
models: ['Match','User','Team'],
stores: ['Match','Team','User'],
refs: [
{
ref: 'insertMatchForm',
selector: '#insertMatchForm'
}
]
},
init: function() {
console.log('Initialized!');
Ext.Viewport.add(Ext.create('FifaKings.view.Main'));
this.control({
'button[action=insertMatchSubmit]' : {
tap: 'insertMatchForm'
},
'list[id=kingsLeagueList]' : {
initialize: 'loadKingsMatches'
}
});
},
insertMatchForm : function(){
var form = this.getInsertMatchForm();
form.submit({
url:'contact.php'
});
},
loadKingsMatches : function(){
console.log('shit is working');
}
});
我的觀點:
Ext.define('FifaKings.view.Kings', {
extend: 'Ext.navigation.View',
requires:[
'Ext.dataview.List'
],
xtype:'kingspanel',
config: {
title: 'Kings',
iconCls: 'star',
items: {
xtype: 'list',
id:'kingsLeagueList',
itemTpl: new Ext.XTemplate(
'<table width="100%" border="0">',
'<tr>',
'<td width=\"35%\">{Player1}</td>',
'<td width=\"30%\" align=\"center\">{ScorePlayer1} - {ScorePlayer2}</td>',
'<td width=\"35%\" align=\"right\">{Player2}</td>',
'</tr>',
'</table>'
),
store: 'Match'
}
}
});
什麼Ext.ComponentQuery.query(名單[ID = kingsLeagueList]')[0]返回在控制檯中? – 2012-07-13 09:39:10
它返回undefined – SnK 2012-07-13 10:29:50
我改變ID爲itemId和現在Ext.ComponentQuery.query('列表[itemId = kingsLeagueList]')[0]確實返回列表,但它仍然不會調用我的方法 – SnK 2012-07-13 10:33:37