In Ember, this is what I do:
I declare these objects
MyObject = Ember.Object.extend({
//some serialization logic
});
FormViewContainer = MyObject .extend({
type: "FormViewContainer",
label: "",
options: {
css: "",
class: "",
attr: []
},
items:[]
});
FormViewField = MyObject.extend({
type: "FormViewLibreField",
isCodif: false,
question: {},
answer: undefined,
options: {
css: "",
class: "",
attr: []
}
});
Then in My app:
var cont = FormViewContainer.create({
label: "My Label",
options: {
class: "cssclassestuff"
}
});
Data.Questions.forEach(function (c) {
var field = FormViewField.create();
field.set("question",c);
cont.get('items').push(field);
});
//items are in the array, they are 6!
cont.get('items').length == 6
Thats the part I dont get. I create a new instance (supposedly), but i
FormViewContainer.create().get('items').length == 6
Object.Create() actually copied items from the other instance into this new one via my object constructor!
It only copied the "items" property, label and options are not affected.
I tried assigning properties with/without the get/set accessors and got the same result.
If anyone has an Idea?