Page 3 of 3 FirstFirst 123
Results 21 to 30 of 30

Thread: getChildren

  1. #21
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Answers
    1
    Vote Rating
    119
      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
      0  

    Default 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
      0  

    Default 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
      0  

    Default 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
    18,593
    Answers
    674
    Vote Rating
    874
      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
    Twitter - @evantrimboli

  6. #26
    Sencha User
    Join Date
    Dec 2007
    Posts
    167
    Vote Rating
    0
      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
    119
      0  

    Default

    Read the DomQuery API docs.

  8. #28
    Sencha User
    Join Date
    Dec 2007
    Posts
    167
    Vote Rating
    0
      0  

    Default

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

  9. #29

  10. #30

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •