1. #21
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Answers
    1
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    How about an extra pseudo operator?
    Code:
    Ext.DomQuery.pseudos.nodeType = function(c, a){
    	var r = [], ri = -1, n;
    	for(var i = 0; n = c[i]; i++){
    		if(n.nodeType == a){
    			r[++ri] = n;
    		}
    	}
    	return r;
    };
    Now you can simply use:
    Code:
    Ext.Element.prototype.getChildren = function(){
    	return this.select('> *:nodeType(1)');
    };

  2. #22
    Sencha User
    Join Date
    Apr 2008
    Location
    West Linton, Scotland
    Posts
    244
    Vote Rating
    0
    andycramb is on a distinguished road

      0  

    Default like it

    like it


    Just did a quick test and it works a treat
    Another great approach
    It also has the benefit of being flexible enough that you can pass in the nodeType you could be looking for.
    I tested for textNodes and it pulled them out as well
    It also seems a natural fit with the other pseudo selectors as there is a pseudo selector that checks the nodeValue.

    Thanks Condor

  3. #23
    Ext User Joe's Avatar
    Join Date
    Apr 2007
    Posts
    243
    Vote Rating
    0
    Joe is on a distinguished road

      0  

    Default Thanks ...

    Thanks ...


    Was looking for how to do this .. I tried tons of stuff

    Ext.Element.prototype.getChildren = function(){
    return this.select('> *:nodeType(1)');
    };
    .. thanks!
    Joseph Francis,
    CoreLan / Meeting Consultants

  4. #24
    Sencha User
    Join Date
    Apr 2008
    Location
    West Linton, Scotland
    Posts
    244
    Vote Rating
    0
    andycramb is on a distinguished road

      0  

    Default flexible and now for getSiblings()

    flexible and now for getSiblings()


    Just to show off its flexible benefits of Condor's approach

    Code:
    Ext.Element.prototype.getSiblings = function(){
              
            //Condor
            return this.select('~ *:nodeType(1)');
    };
    Code:
    Ext.get('pane1').getSiblings()

  5. #25
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Answers
    458
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    I think you're the only person to use the ~ operator. A bug was fixed in it a while back and I don't think anyone noticed
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #26
    Sencha User
    Join Date
    Dec 2007
    Posts
    167
    Vote Rating
    0
    hello2008 is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    I think you're the only person to use the ~ operator. A bug was fixed in it a while back and I don't think anyone noticed
    by the way, where can I get some more reference or examples to learn about the ~ operator?

  7. #27
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Answers
    1
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Read the DomQuery API docs.

  8. #28
    Sencha User
    Join Date
    Dec 2007
    Posts
    167
    Vote Rating
    0
    hello2008 is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    thanks for your quick help, I will read it seriously

  9. #29
    Sencha User
    Join Date
    Apr 2008
    Location
    West Linton, Scotland
    Posts
    244
    Vote Rating
    0
    andycramb is on a distinguished road

      0  

  10. #30