Hi,
I've been using the last version with the MVVM and new DataSource, and I have a problem when adding an entity to a remote DataSource.
After sending the ajax request for adding a new entity, the response is merged with the entity.
This is done in dataSource._accept :
But the Model.accept will extends the model and will override all observable fields by the response from the server.
I have to modify the Model.accept method like this :
if (that instanceof ObservableObject) {
that.init(data);
} else {
extend(that, data);
if (that.idField) {
that.id = that.get(that.idField);
}
}
After the modification, my code works but I strongly believe it's not the good way.
Thanks in advance,
Laurent.
I've been using the last version with the MVVM and new DataSource, and I have a problem when adding an entity to a remote DataSource.
After sending the ajax request for adding a new entity, the response is merged with the entity.
This is done in dataSource._accept :
if (type !== "destroy") {
models[idx].accept(response[idx]);
But the Model.accept will extends the model and will override all observable fields by the response from the server.
I have to modify the Model.accept method like this :
if (that instanceof ObservableObject) {
that.init(data);
} else {
extend(that, data);
if (that.idField) {
that.id = that.get(that.idField);
}
}
After the modification, my code works but I strongly believe it's not the good way.
Thanks in advance,
Laurent.