How to query the child views of a parent view using Titanium?

ra9r picture ra9r · Mar 29, 2011 · Viewed 9.1k times · Source

I am looking to create a general purpose routine that will operate over a view's children. Within the routine I need to be able to iterate over the child views. I don't see anything in the API that would suggest that there is any way to get the child views. There is an "add()" and a "remove()" method but nothing like "get()" nor does there appear to be any properties like "views". What am I missing?

Answer

Aaron Saunders picture Aaron Saunders · Mar 29, 2011

this is the basic structure for removing child objects from a view

    if (view.children) {
        for (var c = view.children.length - 1; c >= 0; c--) {
            view.remove(view.children[c]);
        }
    }