Sencha Touch 2 MVC 列表事件接线
我正在尝试遵循此 Sencha Touch 2 MVC 示例: https://github.com/FrancisShanahan/SenchaTouch2MVCHelloworld 。
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]);
},
});
这里的事件接线有什么问题?
I am trying to follow this Sencha Touch 2 MVC example: https://github.com/FrancisShanahan/SenchaTouch2MVCHelloworld.
The onStationSelect event does not work:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想通了。缺失的部分是:
I figured it out. The missing part was:
这篇文章和教程的组合“如何创建 Sencha Touch 2 应用程序,第 1 部分” 帮助我更好地理解控制器中的
control
和refs
。我想我会分享。A combination of this post and the tutorial 'How to Create a Sencha Touch 2 App, Part 1' helped me understand
control
andrefs
in a controller better. Thought I would share.