I need to create a model having a structure like this:
name: 'xyz',
relatives: [ {name:'abc',age:'123'},{name:'def',age:'123'}..... ]
What i have is a loop which in each iteration generates data for relatives. And i have a model in this state like:
window.Persons.name='xyz'
TWO QUESTIONS
How to push relatives data in this model? I need to understand that how one can construct model instances having nested objects structures to any level?
I am setting the context of model to the window object so that its accessible in all the views as i collect data from different views. Like name is collected in some other view and relatives in some other view and this goes on....So am i doing the right thing? Or i am polluting the global namespace.
Please shed some light as i am sure i am lacking some fundamental understanding here.