add data to json object
Hi
Suppose I have an object call buttonlist.
How do I add more data to this object
var buttonObjects2 = null;
for (var i=0;i<12;i++)
{
buttonObjects2.add({ BG_Options[i], height:33 } );
}
doesn't work as there is no add function…
Help!
3 Answers
-
Accepted Answer
Hi,
For first, you must know what you are trying to do.
If you want to create a matrix, you must declare: var buttonObjects2 = []
and than:buttonObjects2.push() or buttonObjects2[i] = receive something.
But, you seem wanna create a button, so use this
var buttonObjects2 = []
for (var i=0;i<12;i++) { buttonObjects2[i] = Titanium.UI.createButton({BG_Options[i]}); buttonObjects2[i].height=33}
-
Hi Peter
I think .push is the thing to use here.
cheers,
Chris. -
push does the trick!
Thanks!