add data to json object

You must Login before you can answer or comment on any questions.


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...


— asked 5 years ago by Peter Lum

3 Answers

Accepted Answer


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.

Your Answer

Think you can help? Login to answer this question!