相关疑难解决方法(0)

如何将事件处理程序附加到extJS中的面板?

我想要做的就是处理extJS面板上的点击.

我已经尝试了关于这个问题的所有建议以及我在其他地方找到的所有建议,但是每个建议都以下面描述的方式失败了.

将click事件处理程序添加到extJS面板的正确语法是什么?

[ 编辑:为了以后可能会发现这个问题的其他人,我会在内联添加一些注释,以便更容易解读 - @ bmoeskau]

不执行处理程序:

var menuItem1 = new Ext.Panel({
    id: 'panelStart',
    title: 'Start',
    html: 'This is the start page.',
    cls:'menuItem',
    listeners: {
        click: function() {
            alert('ok');
        }
    }
}); 
Run Code Online (Sandbox Code Playgroud)

[Ed:click不是小组活动]

不执行处理程序:

var menuItem1 = new Ext.Panel({
    id: 'panelStart',
    title: 'Start',
    html: 'This is the start page.',
    cls:'menuItem',
    listeners: {
        render: function(c) {
            c.body.on('click', function() {
                alert('ok');
            });
        }
    }
}); 
Run Code Online (Sandbox Code Playgroud)

[Ed:面板永远不会被渲染 - 添加renderTo配置.接下来,您将遇到一个空错误,告诉您这c …

events extjs event-handling

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

event-handling ×1

events ×1

extjs ×1