PDA

View Full Version : OnClick event on particular element in Xtemplate



Madhu Sudhan C S
30 Jul 2013, 6:10 AM
Hi,
I have requirement to gain access to panel obj from onclick event handler.
The element is generated using Xtemplate.
This is the piece of code
<div onclick="showXXX(this)"></div>

But 'this' is div element and not the component(panel).
Can you please help me to solve this?

Regards,
--Madhu C S

stevenbrent
31 Jul 2013, 1:09 PM
In general, you want to avoid hardcoding event listeners in your HTML and delegate those to a controller. Can you post a complete code snippet for this? What is the object that needs to send the onclick? The div, or the panel inside it? Or some content within the panel?...


Hi,
I have requirement to gain access to panel obj from onclick event handler.
The element is generated using Xtemplate.
This is the piece of code
<div onclick="showXXX(this)"></div>

But 'this' is div element and not the component(panel).
Can you please help me to solve this?+ Reply to Thread (http://www.sencha.com/forum/newreply.php?p=984921&noquote=1)

Regards,
--Madhu C S

Madhu Sudhan C S
31 Jul 2013, 8:15 PM
me.tpl = Ext.create('Ext.XTemplate',
'<div>',
'<div >'+me.headerText+' </div>',
'<tpl for=".">',
'<tpl if="this.isEqualToLimit(xindex,values)"> ' +
'<div onclick="showXXX(panelObj)"> {[this.getPlusMoreTxt(xindex, xcount)]} </div>',
'<tpl elseif="this.greaterThanPlusMoreLimit(xindex, values)">', // If greater than plusMoreLimit don't do anything.
'',
'<tpl else>',
'<div >',
'<div > {[this.getUserInputValue(values)]} </div>',
'<div > {[this.getTranslatedValue(values)]} </div>',
'</div>',
'</tpl>',
'</tpl>',
'</div>');


OnClick I need to send the panel object.