Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Model view controller Sencha Touch 2 MVC列表事件接线_Model View Controller_List_Events_Sencha Touch - Fatal编程技术网

Model view controller Sencha Touch 2 MVC列表事件接线

Model view controller Sencha Touch 2 MVC列表事件接线,model-view-controller,list,events,sencha-touch,Model View Controller,List,Events,Sencha Touch,我试图遵循这个Sencha Touch 2 MVC示例: 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 componen

我试图遵循这个Sencha Touch 2 MVC示例:

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]);
},
});

这里的事件连线有什么问题吗?

我找到了答案。缺少的部分是:

this.control({
    'list' : {
        itemtap : this.onStationSelect
    }
});

我想出来了。缺少的部分是:

this.control({
    'list' : {
        itemtap : this.onStationSelect
    }
});

这篇文章和我的研究相结合,帮助我更好地理解了控制器中的
控制
参考
。我想我会与大家分享。

这篇文章的组合,帮助我更好地理解控制器中的
控制
参考
。我想我会分享