-
13 Sep 2009 11:22 AM #1
Unanswered: first-sibling
Unanswered: first-sibling
Hi, I try to select first sibling td's id on click.
Code:Ext.onReady(function(){ Ext.select("table").on("click", function(e,t){ e.stopEvent(); Ext.get(t).first(); //jQuery: $(e.target).siblings("td:first") }); });any help would be appreciated.HTML Code:<table> <tr> <td id="foo">alfa</td><td>beta</td> </tr> <tr> <td id="bar">alfa</td><td>beta</td> </tr> </table>
-
13 Sep 2009 10:10 PM #2Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
Code:Ext.override(Ext.Element, { siblings: function(s) { var n = this.dom.parentNode, r, c, i, l, rl; if(s) { r = Ext.DomQuery.select('/' + s, n); for (i = 0, rl = r.length; i < rl; i++) { if (r[i] === this.dom) { r.splice(i, 1); return r; } } } else { r = []; c = n.childNodes; for (i = 0, rl = c.length; i < rl; i++) { if (c[i] !== this.dom) { r.push(c[i]); } } return r; } } });Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
19 Sep 2009 7:00 AM #3
Thanks Animal. I think such methods should be added to the Ext Core.
-
19 Sep 2009 11:51 PM #4Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
Maybe. But there are several dozen ways to skin any cat. eg:
Code:Ext.onReady(function(){ Ext.select("table").on("click", function(e,t){ e.stopEvent(); Ext.get(t).up('tr').first(); }); });Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642


Reply With Quote