PDA

View Full Version : Ext. select



nick saint
15 Feb 2010, 2:49 PM
Hi, I have faced a little missunderstanding with Ext.select. I have the following HTML code



<table>
<tbody><tr>
<td id="A-menu"><a id="A-link"><span>A item</span></a></td>
<td id="B-menu"><a id="B-link"><span>B item</span></a></td>
</tr></tbody>
</table>

by means of Ext.select I need to get TD id.
I do:


Ext.select("td[id$='-menu']").addListener({
'click' : {
fn: function(e, el){
alert(el.id);
},
scope: this,
delay: 100
}
});
Looks like I do something wrong as I get empty alert. I guess the click refers to the SPAN element and not to TD.
Pls, help to understand what I do wrong
Thank you
Nick

tobiu
15 Feb 2010, 10:22 PM
ext.select is wrong for this.
according to the api:



select( String/Array selector, [HTMLElement/String root] ) : CompositeElementLite/CompositeElement
Selects elements based on the passed CSS selector to enable Element methods to be applied to many related elements i...
Selects elements based on the passed CSS selector to enable Element methods to be applied to many related elements in one statement through the returned CompositeElement or CompositeElementLite object.
Parameters:

* selector : String/Array
The CSS selector or an array of elements
* root : HTMLElement/String
(optional) The root element of the query or id of the root

Returns:

* CompositeElementLite/CompositeElement


Ext.get() should fit better ;)

kind regards,
tobiu

nick saint
16 Feb 2010, 9:38 AM
Thank you
Same day I figured out how to solve this case. I do not know if it's the right way to do, but it works fine to me.


Ext.select("table[id='navBar']").addListener({
'click' : {
fn: function(e, el){
var td = Ext.get(el).up('td');
alert(td.id);
}
});

Nick