2015-02-24 91 views
1

我有一個自定義組件鏈接到一個html tpl,我需要當我點擊這個鏈接組件激發一個事件,我在控制器中偵聽。ExtJS 4.2自定義組件點擊一個tpl鏈接時觸發事件

代碼:

分機

Ext.define("Ext.ux.newpanel.NewPanel", { 
    extend: 'Ext.Component', 
    ... 
tpl: [ 
    '<div class="title center"><p>{title}</p></div>', 
    '<div class="content center">', 
    '<div class="number center"><h1>{qtd}</h1></div>', 
     '<div class="ind left">', 
     '{ind}', 
     '</div>', 
    '</div>', 
    '<div class="more">', 
    '<a href="#" class="clickme">See all...</a>', 
    '</div>' 
    ], 
... 

我tryed來創建代表團監聽器,但我不能讓組件範圍爲聽衆。 代碼:

.. 
listeners: { 
    // Add the listener to the component's main el 
    el: { 
     delegate: '.clickme', 


     click: function(ev, li) { 
     // need to fire event in component here 
     } 
    } 
    }, 
... 

事件需要在「clickme」類中觸發。

謝謝!

+0

這已經被問及在這篇文章中回答http://stackoverflow.com/questions/8794148/how-do-you-attach-click-events-to-extjs-template-elements – mindparse 2015-02-24 20:21:56

+0

爲我工作的一個一點修改,我會作爲答覆發佈 – 2015-02-25 13:54:11

回答