ExtJS中listener方法和handler方法的區別

來源:互聯網
上載者:User

標籤:lan   doc   check   width   listeners   blog   first   官方   read   

listener方法和handler方法的區別在文檔中的說明的太玄乎了,看不懂

listeners監聽能夠對一個click Event事件添加任意多個的事件響應處理函數

而handler處理只能夠通過處理函數一次處理點擊響應

Ext.create(‘Ext.Button‘, {    text    : ‘Dynamic Handler Button‘,    renderTo: Ext.getBody(),    handler : function() {        // this button will spit out a different number every time you click it.        // so firstly we must check if that number is already set:        if (this.clickCount) {            // looks like the property is already set, so lets just add 1 to that number and alert the user            this.clickCount++;            alert(‘You have clicked the button "‘ + this.clickCount + ‘" times.\n\nTry clicking it again..‘);        } else {            // if the clickCount property is not set, we will set it and alert the user            this.clickCount = 1;            alert(‘You just clicked the button for the first time!\n\nTry pressing it again..‘);        }    }});
new Ext.panel.Panel({    width: 400,    height: 200,    dockedItems: [{        xtype: ‘toolbar‘    }],    listeners: {        click: {            element: ‘el‘, //bind to the underlying el property on the panel            fn: function(){ console.log(‘click el‘); }        },        dblclick: {            element: ‘body‘, //bind to the underlying body property on the panel            fn: function(){ console.log(‘dblclick body‘); }        }    }});

-------------------------------------------------------------------------------------------------------------------------------------------

官方說法可以點擊此處

ExtJS中listener方法和handler方法的區別

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.