首页 > 解决方案 > 为什么监听器不工作?

问题描述

为什么第一个监听器不工作而另一个监听器工作?

如何设置第一个监听器工作?

也许问题与范围有关,这个?

如何设置它以查看 MainControllers 中可用的功能?

是现代版ExtJS 6.2

结构文件夹:

//FeedViewer
    //app
        //view
           //main
               /MainController.js
               /MainModel.js
              /FeedForm.js
             /Feeds.js
    //classic
    //modern
        //src
            //view
                //main
                    /Main.js

主控制器.js:

Ext.define('FeedViewer.view.main.MainController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.main',

     onNewFeed: function () {
        alert('Hello');
    }
});

Feeds.js:

Ext.define('FeedViewer.view.main.Feeds', {
    extend: 'Ext.grid.Grid',

    xtype: 'feedslist',

    requires: [
        'ContactsApp.view.feeds.MainController',
        'ContactsApp.view.feeds.MainModel'
    ],

    viewModel: 'feeds',
    controller: 'feeds',

    columns: [{
        dataIndex: 'feed',
        text: 'feed'
    }],

    items: [{
        xtype: 'toolbar',
        docked: 'left',
        items: [{
            xtype: 'button'
            text: 'Add New Feed',
            iconCls: 'fa fa-plus',
            listeners: {
                click: 'onNewFeed' * * //It doesn't work**
            }
        }]
    }],
    listeners: {
        select: 'onNewFeed' * * //It  works**
    }
});

标签: javascriptextjs

解决方案


在现代工具包Ext.Button中,点击事件被称为tap. 你也可以使用handler配置。这是小提琴


推荐阅读