Created
June 9, 2011 00:22
-
-
Save jonalter/1015781 to your computer and use it in GitHub Desktop.
Remove a window's children
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var win = Ti.UI.createWindow({ | |
| backgroundColor: 'white' | |
| }); | |
| var view1 = Ti.UI.createView({ | |
| backgroundColor: 'red', | |
| height: 100, | |
| width: 50, | |
| top: 20, | |
| left: 20, | |
| isTitle: true | |
| }); | |
| var view2 = Ti.UI.createView({ | |
| backgroundColor: 'green', | |
| height: 100, | |
| width: 50, | |
| top: 20, | |
| left: 90 | |
| }); | |
| var view3 = Ti.UI.createView({ | |
| backgroundColor: 'blue', | |
| height: 100, | |
| width: 50, | |
| top: 20, | |
| left: 160, | |
| isTitle: true | |
| }); | |
| var button = Ti.UI.createButton({ | |
| title: 'Open', | |
| height: 60, | |
| width: 200, | |
| bottom: 20 | |
| }); | |
| button.addEventListener('click', function(e){ | |
| var children = win.children; | |
| var length = children.length; | |
| // alert('win has ' +length+ ' children'); | |
| for(var i = 0; i<length; i++){ | |
| Ti.API.info("i: "+i+" children[i].isTitle: "+children[i].isTitle); | |
| if (children[i].isTitle) { | |
| win.remove(children[i]); | |
| } | |
| } | |
| }); | |
| win.add(view1); | |
| win.add(view2); | |
| win.add(view3); | |
| win.add(button); | |
| win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment