I was looking to see if there is a method that can pull back all the children of an element
I cannot see anything that does this at the moment
So from the html below I want to get all the divs under the wrapper div from something like this

Ext.get('wrapper').getChildren()Can I /should I poke this into the Ext.Element prototype?
Is there any existing methods I can use to achieve this
I am kinda lost in between Ext,Ext.Element, Ext.DomQuery
Any help is much appreciated

Thanks for your help
I maybe should have explained that I was thinking that I may not know the tag name, the id or class so would want something that could return a composite element based on structure
and then I could chain other methods for example

Ext.get('wrapper).getChildren().hide();

hendricd

24 Jun 2009, 11:32 AM

Ext.Element has a variety (http://extjs.com/products/extcore/docs/?class=Ext.Element) of methods available.

andycramb

24 Jun 2009, 12:17 PM

Thanks but I have been looking at the Element class for a while now without a light bulb moment

Or you can use query and get back an array as detailed by hendricd earlier.

Hope that helps

andycramb

24 Jun 2009, 2:50 PM

Thanks Joe for the help as well

What I am trying to achieve is port over a MooTools sliding tab extension in to ExtJs core
I have an early prototype how it works using MooTools at the moment on my site (http://www.cramb.org.uk/slidingtabs/index_v3.html) to give you an idea of what I am trying to do. I am at the moment trying to do write an extension for Ext Core

I was looking for the child sections to be configurable so it maybe divs,uls or even tables. It would be up to the user implementing the structure to decide what there html would be
The extension I hope to write would not care what tags/html that was used, but would just get all the children under the wrapper div. It would be flexible enough to accommodate any tags as long as they were children of the wrapper div
So when I called getChildren it could return all child elements

I understand what yourself and hendricd have all already posted but I am looking for some more flexibility and I was also hoping to pick up how to add methods to Ext.Element and therefore understand some more about the Core while I was at it

Hope that makes sense
Thanks to both of you for your help

andycramb

25 Jun 2009, 7:09 AM

I am nudging closer to what I was looking for
I have got the basics up and running by doing this

I tried this earlier and abandoned it because it returned 11 items when I was expecting just the 5 divs. I couldnt quite understand at the time and thought it was maybe also selecting TextNodes or lineBreak as a node. That is why I thought I should check if the nodeType was equal to 1
Maybe you can understand what its doing as the first few items in the elements object are this based on

You won't see the DomQuery updated to exclude the text entries, but here is an idea.

If you want to use select and get back a CompositeElementLite and you normally loop through the results using each, then the most efficient option may to add a new function to the CompositeElementLite called eachEl. Such a function which would skip the text node types. In this case the count would still show 11 but when you loop through, it only hits the five you want.

@Joe -- :)
And what if I wanted all the empty textNodes (for replacement) whose previous sibling had an attribute bra="large" ?

Got an override for that?

That sort of filtering belongs in your application logic, especially considering all the possible CSS selector variants one might use in developing stuff for Core (or any framework).

IMHO: Javascript has plenty of Array.prototypes to handle that sort of thing. Let's not bloat Core for narrow use-cases.

But, hey, go nuts! ;)

andycramb

25 Jun 2009, 2:18 PM

@ Joe Thanks for your help
I will apply those techniques and go through them in Firebug
Certainly there are many ways to do this and one of them may prove more useful as I add the rest of the functionality
I will certainly take the learning as best I can. I may have some questions
In fact where does the el(bold) come from in here?

@andy ... one is for scope and the other is the first param of the function call.

@hendricd - you are obviously one of the smartest people arount and I have nothing but respect for you .. you are correct in what you say.

I knew that post would get answers like this ..

That sort of filtering belongs in your application logic, especially considering all the possible CSS selector variants one might use in developing stuff for Core (or any framework).

In fact, I agree about most of this should be at the app level and hence my "tossing out ideas" .. not "here is how you should do it".

At the same time ... pulling DOM nodes using a selector and then filtering out the text nodes so you get back the same set of nodes with all browsers / that you really need / is another story. I can see a valid use for having such a function at a base level / built in so I provided such a solution for anyone that desires such a solution.

hello2008

26 Jun 2009, 1:06 AM

I would disagree with that. What if you wanted the textNodes?

Ext.select/query strengths are in their generic use, to get anything via a valid CSS selector.

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.

i have an issue regarding field-set expand/collapse. i have a container containing multiple drop downs. on container mouse over event i expand that particular container and on mouse leave collapse that container. i faced an issue, when i trying to select any record from drop down container get collapsed, at that time mouse leave event hit. is there any way to retain the container info so it cannot get collapse on selection value from drop down. it only collapse when mouse is out of the container. any kind of help will be appreciable. Thanks in Advance !!!