BUG
----
Currently, when
Ti.UI.View.children
is queried, the live copy of children is returned, meaning that if it is modified in-place during a loop (which might be a common operation) there are some issues. Even worse, it follows copy semantics before a view is put into the full hierarchy, and reference semantics after.
INITIAL DESCRIPTION
----
Feature description
Provide an easy way to clean the contents of a view/window, like a magic "remove all children" that will remove them in the right order.
Current behavior
Customer is trying to do this:
for(var i=0;i<parent.children.length;i++)
{
parent.remove(parent.children[i]);
}
which causes a crash in the app because they are removing stuff without any order. Maybe we should provide a tree with all the dependencies in the view, so they can be properly removed.
Here is my solution: https://gist.github.com/1779850 (and explanation why it does not work with "customer's way")
Testing
---- * Run the following code sample - no interactions necessary. Note that the long delays are necessary due to inefficiencies in the rendering system. Also note that there may be occasional errors as the system tries to remove the same view more than once - this is becauseremove()
is asynchronous. This is not a fatal error.There is a separate issue with
Ti.UI.View.children
beingundefined
when the view does not have children. This may be a problem on Android as well, and we are investigating the parity problem.Closing issue Tested with Ti Studio build 2.1.0.201206211609 Ti Mobile SDK 2.1.0.v20120622174154 hash rdc9dfbe5 OSX Lion 10.7.3 iPhone 4S OS 5.1 Verified expected behavior is shown