开发者

Problem with model.set() method

开发者 https://www.devze.com 2023-01-04 13:54 出处:网络
I am facing problems in setting model values containing numeric properties. Here is the example: This code does not work:

I am facing problems in setting model values containing numeric properties. Here is the example:

This code does not work:

var modelSkeleton = {id: null, name: null};
var model = rx.data.marshal.Json.createModel(modelSkeleton);
var x = {id:22,name:"New name"};
model.set(x);

However if I put quotes on id value, it works:

var modelSkeleton = {id: null, name: null};
var model = rx.data.marshal.Json.createModel(modelSkeleton);
var y = {id:"22",name:"New name"}
model.set(y);

Am I doing some mistake or t开发者_开发技巧his is a bug? Any quick solution?


I think there is something missing of the concepts of the qooxdoo data binding. For that, you need to know what your second line in your code is doing. This one brings you a bit of magic which creates a qooxdoo class based on your JavaScript object and instanciates an object of it which is returned. All the properties attached to your native JavaScript object will be available as qooxdoo properties which have to be accessed with the commonly used getter and setter. The set method you use is just a shortcut which parses your given object and sets each property contained. So usually that should work but its important to know what you are doing here because there are restrictions when you have more complex objects like arrays, this way is not working.

Regards,
Martin
Btw. its always qx and not rx. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号