- Create HTML text using html tag or xtemplate.
- Assign classname/id to the component to which you want to attach an event.
- Attache event to the Ext body and delegate to the specific class/id show in below.
- Make sure that class name or id is unique.
Here is the fiddle to fiddle around with it.
Sample snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
values = [{ | |
id : 'v1', | |
name : 'Value1' | |
}, { | |
id : 'v2', | |
name : 'Value2' | |
}, { | |
id : 'v3', | |
name : 'Value3' | |
}, { | |
id : 'v4', | |
name : 'Value4' | |
}, { | |
id : 'v5', | |
name : 'Value5' | |
}]; | |
var tpl = new Ext.XTemplate( | |
'<p>Values: ', | |
'<tpl for=".">', | |
'<div style="display: inline-block" data-valueid="{id}" class="values-class">{name}</div><br/>', | |
'</tpl></p>'); | |
var panel = Ext.create('Ext.panel.Panel', { | |
renderTo : Ext.getBody() | |
, | |
}); | |
tpl.overwrite(panel.body, values); | |
var el = Ext.getBody(); | |
el.on('mouseover', function(e, t, eOpts) { | |
alert(t.getAttribute('data-valueid')); | |
}, this, { | |
delegate : '.values-class' | |
}); |
No comments:
Post a Comment