I am trying to add a new entity to an existing array in an upshot viewmodel. The entity is JSON returned from the server and one of its properties is an array. This part works properly with all related entities mapped
var promo = {};
var promoType = {};
var promoModel = "Promo:#CodeFirst.Models";
upshot.map(json[0], promoModel, promo);
upshot.addEntityProperties(promo, promoModel);
However when I push the new upshot entity into the KO array it loses its array of child entities - just an empty array remains with all other properties ok.
issue.Promos.push(promo);
has anyone else had this problem or better yet resolved it?
Joemurai
0 Points
2 Posts
Child entity getting removed on ko.push
Mar 30, 2012 03:18 PM|LINK
Hi,
I am trying to add a new entity to an existing array in an upshot viewmodel. The entity is JSON returned from the server and one of its properties is an array. This part works properly with all related entities mapped
var promo = {}; var promoType = {}; var promoModel = "Promo:#CodeFirst.Models"; upshot.map(json[0], promoModel, promo); upshot.addEntityProperties(promo, promoModel);However when I push the new upshot entity into the KO array it loses its array of child entities - just an empty array remains with all other properties ok.
has anyone else had this problem or better yet resolved it?
Cheers
Joe
KDegrave
Member
96 Points
25 Posts
Re: Child entity getting removed on ko.push
Apr 13, 2012 06:02 AM|LINK
My experience with adding data is that you have to define your model as a JS Object and make al the properties of the object observable.
If that doesn't help, I think you will have to provide some more information so I can go and search for the issue.
greetings
Kristof
Ria4HTML: http://ria4htmldemo.codeplex.com
Linq2IndexedDB: http://linq2indexeddb.codeplex.com