[英]Sencha Touch 2 MVC list event wiring
I am trying to follow this Sencha Touch 2 MVC example: https://github.com/FrancisShanahan/SenchaTouch2MVCHelloworld . 我正在尝试遵循此Sencha Touch 2 MVC示例: https : //github.com/FrancisShanahan/SenchaTouch2MVCHelloworld 。
The onStationSelect event does not work: onStationSelect事件不起作用:
Ext.define('HelloWorld.controller.Home', {
extend: 'Ext.app.Controller',
views: ['Home', 'SimpleList'],
stores: ['Stations'],
// These "refs" will generate "getters" for each of the view component instances
// e.g. getBottomField and getStationList
refs: [{
selector: 'carousel > panel > #bottomInput',
ref: 'bottomField'
},
{
selector: 'carousel > list',
ref: 'stationList'
}
],
init: function() {
console.log('Init home controller');
// Start listening for events on views
this.control({
// example of listening to *all* button taps
'button': { 'tap': function () {
console.log('Every button says Hello world');
}
},
// Example of listening by an explicit id
'#firstButton': { 'tap': function () {
console.log('Only the button with id=firstButton says Hello');
alert(this.getBottomField().getValue());
}
}
});
},
onLaunch: function() {
console.log('onLaunch home controller');
// The "getter" here was generated by specifying the
// stores array (above)
var stationsStore = this.getStationsStore();
stationsStore.load({
callback: this.onStationsLoad,
scope: this
});
},
onStationsLoad: function() {
console.log('onStationsLoad home controller');
// get a reference to the view component
var stationsList = this.getStationList();
// do something
},
onStationSelect: function(selModel, selection) {
// Fire an application wide event
this.application.fireEvent('stationstart', selection[0]);
},
});
What is wrong with the event wiring here? 这里的事件接线有什么问题?
I figured it out. 我想到了。 The missing part was: 缺少的部分是:
this.control({
'list' : {
itemtap : this.onStationSelect
}
});
A combination of this post and the tutorial 'How to Create a Sencha Touch 2 App, Part 1' helped me understand control
and refs
in a controller better. 这篇文章和教程“如何创建Sencha Touch 2应用程序,第1部分”相结合,帮助我更好地理解了控制器中的control
和refs
。 Thought I would share. 以为我会分享。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.