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

2

5

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?

Nudnik answered 29/3, 2011 at 15:25 Comment(0)
F
9

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]);
        }
    }
Frogmouth answered 29/3, 2011 at 16:20 Comment(1)
Maybe something like this answer, and the answer from mkind: if (view.children) { for (var i=0; i<view.children.length; i++) { if (view.children[i] !== undefined) { view.remove( view.children[i] ); } } }Alithia
F
4

i would check also for

if (view.children[c] !== undefined) {..}

since i already got problems with android without verifieing.

Flytrap answered 1/8, 2011 at 9:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.