Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 288
ra9r Avatar asked Mar 29 '11 15:03

ra9r


2 Answers

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]);
        }
    }
like image 158
Aaron Saunders Avatar answered Nov 15 '22 02:11

Aaron Saunders


i would check also for

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

since i already got problems with android without verifieing.

like image 20
mkind Avatar answered Nov 15 '22 04:11

mkind