Sencha Touch 2错误:无法读取undefined属性'apply'

时间:2015-04-10 06:02:20

标签: javascript sencha-touch-2

我有以下Sencha Touch代码。一个简单的列表视图。

{
            xtype: 'list',
            itemId: 'stockitemslist',
            ui: 'normal',
            flex: 1,
            onItemDisclosure: false,
            preventSelectionOnDisclose: false,
            itemTpl: '<div class="act-list">'+
                '<table width="100%">'+
                '<tr>'+
                '<td  width="10%"><img align="left" src="img/icon_check2.png"/></td>'+
                '<td  width="80%"><b>&nbsp; {MaterialDesc}</b></td>'+
                //'<td  width="10%" ><img align="right" src="img/icon_list_disclosure.png"/></td>'+
                '</tr>'+
                '</table>'+
                '</div>'
        }

我想在点击列表视图的项目后设置警报。在我的控制器中,我试着跟随。

Ext.define('net.omobio.dialog.dialogcc.controller.StockAvailability', {
extend: 'Ext.app.Controller',
/*requires: [
    'net.omobio.dialog.dialogcc.store.StockItems'],*/
config: {
    refs: {
        maincard: 'stockitemsmain #cardview',
        StockItems: 'Stock_items',
        StockItemList: 'Stock_items #stockitemslist'

    },

    control: {
        'StockItemList': {
            itemtap: 'onStockItemlistTap'
        }
    },

    routes: {
        'bucketlist': 'loadbucketlist'
    },

    onStockItemlistTap: function(list, index, target, record, event) {
        console.log('Item was tapped on the Data View');
        console.log(list, index, target, record, event);
        Ext.Msg.alert('', 'The material code selected is: ' + record.get('MaterialCode'));
        var me = this;
        console.log('record');
        console.log(record);
        console.log('index');
        console.log(index);

    },

    loadbucketlist: function() {
        console.log('xxxx Bucket List');
        //this.showView('docrecoverydsr.ConnectionList');

    }

}

});

但是一旦我点击了一个项目就会出现以下错误。

Uncaught TypeError: Cannot read property 'apply' of undefined

任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:0)

请尝试以下代码

Ext.define('net.omobio.dialog.dialogcc.controller.StockAvailability', {
    extend: 'Ext.app.Controller',
   /*requires: [
            'net.omobio.dialog.dialogcc.store.StockItems'],*/
   config: {
     refs: {
        maincard: 'stockitemsmain #cardview',
        StockItems: 'Stock_items',
        StockItemList: 'Stock_items #stockitemslist'

      },

      control: {
        StockItemList: {
            itemtap: 'onStockItemlistTap'
        }
      },

     routes: {
        'bucketlist': 'loadbucketlist'
     }
    },

    onStockItemlistTap: function(list, index, target, record, event) {
        console.log('Item was tapped on the Data View');
        console.log(list, index, target, record, event);
        Ext.Msg.alert('', 'The material code selected is: ' + record.get('MaterialCode'));
        var me = this;
        console.log('record');
        console.log(record);
        console.log('index');
        console.log(index);

    },

    loadbucketlist: function() {
        console.log('xxxx Bucket List');
        //this.showView('docrecoverydsr.ConnectionList');

    }



});