View Full Version : Help With DOM

19 Nov 2010, 4:24 PM
Hey I have a list and I want to know if there is a way to check which link in the list was clicked.

for example

I want to be able to check which id was clicked.

this works

Ext.select("ul li a").on('click', function(t, ref){

but it only works on the link without the image if i click the lick with the image I get the image and not the link id.

is there a way to only get the links id so i can make a conditional statement?

thanks for any help.

20 Nov 2010, 9:56 AM
No help here? I am having no luck on my own.

22 Nov 2010, 10:03 AM
The target of the click is actually the image, so you're going to have to do a little bit of evaluation:

Ext.select("ul li a").on('click', function(t, ref){
var desiredId = ref.id;

if (ref.parentNode.tagName == 'A') {
desiredId = ref.parentNode.id;


23 Nov 2010, 6:57 AM
Inefficient. You should use a single click handler with a delegate, e.g.

Ext.select('ul').on('click', function(e, t) {
var id = t.id;
}, null, {delegate: 'a'});