Object Attributes are Read Only?
Given the sample code here: http://pastie.org/880442
I am trying to figure out if I have a basic misunderstanding of javascript, or if Ti is doing something wacky. What I am trying to do is create some additional attributes on a UI object (in this example, a View). I do this by creating the View, and then creating a new object and assigning it to view.info (on line 9).
The trouble comes in when I try to change an attribute of this info object (line 18), and the value of that attribute doesn't change (lines 32 and 34 print the same thing - the value is 0, and not 1 as it should be based on line 18).
Any thoughts on what is going on?
2 Answers
-
Accepted Answer
I think Ti is doing something wacky. Or rather I think it's magic it works at all - how on earth do they do it? ;)
However, what if you try changing the property and then resetting the whole object like this?:
function moveView( view ){ view.left = 100; view.right = 100; var info = view.info; info.moved = 1; view.info = info; }
It's not as pretty, but at least I think this will trigger Ti to update the object. However, it would seriously rock if they fixed direct property setting!
-
An excellent workaround, Jacob. Tho I concur about hoping this actually gets fixed.