为Ext.form.Panel的xtype:label添加事件

需求

在Ext.form.Panel中添加文字,并注册click事件。
实现如效果图所示的功能

效果图

为Ext.form.Panel的xtype:label添加事件_第1张图片
为Ext.form.Panel的xtype:label添加事件_第2张图片\

核心

为xtype:label添加事件

 listeners: {
      render: function () {//渲染后添加click事件
           Ext.select("#pipeSecrecyAgreement").on('click',
               function (e, t) {
                   agreementWin.show();
               });
       },
       scope: this
   }

代码

 items:[
                {
                    xtype:"checkbox",
                    id:"optionAgreement",
                    width:30,
                    height:30,
                    margin:"10 0 0 650",
                    handler: function() {
                    }
                },
                {
                    xtype: "label",
                    id:"pipeSecrecyAgreement",
                    width: 150,
                    height: 30,
                    text: '同意管线保密协议',
                    margin: " 10 0 0 0",
                    border: 0,
                    style: "text-decoration: underline;color:red;",
                    listeners: {
                        render: function () {//渲染后添加click事件
                            Ext.select("#pipeSecrecyAgreement").on('click',
                                function (e, t) {
                                    agreementWin.show();
                                });
                        },
                        scope: this
                    }
                }
       ]

你可能感兴趣的:(ExtJs)