简体   繁体   中英

Knockout.js toJSON creating null objects from Breeze entities

Using Breeze and Knockout together so far without problems. But just run into some really odd behaviour.

It's going to be hard to reproduce or post code, but I'm going to ask the question anyway in the hope it rings a bell somewhere. Essentially the problem is that if I change or add an object in this particular instance, and then save, when I call ko.toJSON() on the entitiy, it replaces all the new/changed objects with null values.

The same serialisation code works fine for all the other objects so far, so it must be the entitiy itself which is somehow different. But looking at the objects, there's nothing obvious - although since knockout wraps everything in observables it'd be hard to spot anyway.

Apologies for the lack of information but I'm badly stumped - does this ring any bells for anyone?

Why are you ever calling ko.toJSON? Breeze automatically wraps and unwraps your entities for you when saving. Or is there some other reason, ( other than saving), for calling ko.toJSON?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM