惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
G
GRAHAM CLULEY
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志
L
Lohrmann on Cybersecurity
S
Security @ Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Security Affairs
The Cloudflare Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
Y
Y Combinator Blog
V2EX - 技术
V2EX - 技术
罗磊的独立博客
F
Full Disclosure
Jina AI
Jina AI
S
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recorded Future
Recorded Future
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
K
Kaspersky official blog
V
Visual Studio Blog
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
Tor Project blog
Cloudbric
Cloudbric
Hacker News - Newest:
Hacker News - Newest: "LLM"
爱范儿
爱范儿
L
LINUX DO - 最新话题
GbyAI
GbyAI
Attack and Defense Labs
Attack and Defense Labs
H
Heimdal Security Blog
Recent Announcements
Recent Announcements
L
LINUX DO - 热门话题
L
LangChain Blog
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - lwjacky

SQL提高查询效益之in、not in、between、like等条件讲述 sqlserver查询数据的所有表名和行数 Extjs4---Cannot read property 'addCls' of null ExtJs4.1实现数据缓存 Sql 脚本文件太大 系统操作日志设计 一种简单的直观的高效的权限设计 ExtJs 常用方法 属性 C#农历类 通过C#使用googleAPI SQL SERVER 如何批量修改表和存储过程的架构 HTML特殊转义字符列表 - lwjacky - 博客园 extjs3.0 修正 ie 与 firefox字体显示差异的补丁 C#实现QQ接口软件--QQ的HTTP接口协议探究 二次开发WinWebMail邮件系统接口 C#实现汉字转换为拼音缩写的代码 C#实现将汉字转化为拼音的代码 extjs IE8下datefield的width问题 自己的工具箱(Toolkit)
ExtJS中如何给Label添加click事件
lwjacky · 2009-11-12 · via 博客园 - lwjacky

     ExtJS中Ext.form.Label默认是没有click事件的,但由于项目需要,要求给label添加一些其它的事件,本文提供两种方法对这个class进行扩展,方法如下:

方法1:

Ext.onReady(function() {
   var p = new Ext.ux.MyPanel({
      renderTo : document.body
     });
  });
Ext.ux.MyPanel = Ext.extend(Ext.Panel, {
   initComponent : function() {
    Ext.apply(this, {
       width : 200,
       height : 200,
       items : [{
        xtype : 'label',
        id : 'mylabel1',
        html : 'Label 1',
        listeners : {
         render : function() {//渲染后添加click事件
          Ext.fly(this.el).on('click',
            function(e, t) {
             // do stuff
             alert('Hi');
            });
         },
         scope : this
        }
       }]
      });
    Ext.ux.MyPanel.superclass.initComponent.call(this);
   }
  });

方法2:

Ext.onReady(function() {
            //在渲染后添加click事件
   Ext.form.Label.prototype.afterRender = Ext.form.Label.prototype.afterRender
     .createSequence(function() {
        this.relayEvents(this.el, ['click']);
       });//这一段一定要放在label之前
   var tempPanel = new Ext.Panel({
      layout : 'fit',
       renderTo : document.body,
      items : [{
         xtype : 'label',
         text : 'label click',
         listeners : {
          'click' : {
           fn : function(field) {
            alert("Hi");
           },
           scope : this
          }
         }
        }]
     });
  });