1. #1
    Ext User
    Join Date
    Jun 2009
    Posts
    2
    Vote Rating
    0
    jsonx is on a distinguished road

      0  

    Default 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")
            });
        });
    HTML Code:
        <table>
            <tr>
                <td id="foo">alfa</td><td>beta</td>
            </tr>
            <tr>
                <td id="bar">alfa</td><td>beta</td>
            </tr>
        </table>
    any help would be appreciated.

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Answers
    13
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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;
            }
        }
    });

  3. #3
    Ext User
    Join Date
    Jun 2009
    Posts
    2
    Vote Rating
    0
    jsonx is on a distinguished road

      0  

    Default


    Thanks Animal. I think such methods should be added to the Ext Core.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    57
    Answers
    13
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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();
            });
        });

Thread Participants: 1