Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created June 9, 2011 00:22
Show Gist options
  • Select an option

  • Save jonalter/1015781 to your computer and use it in GitHub Desktop.

Select an option

Save jonalter/1015781 to your computer and use it in GitHub Desktop.
Remove a window's children
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