mercredi 15 avril 2015

How to force ember data to reset all fields of a record on reload?

I am using ember with ember data and i have a scenario where I need to reload a model. On reload, when the data is fetched and some fields of that model are null, the older data still persists. For eg., if I have a Post model



App.Post = DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
});


Now the first time the server returns the following data:



{
"post" : {
"id" : "1",
"name" : "new post",
"description": "some description"
}
}


After reload is called, the server returns the following data:



{
"post" : {
"id" : "1",
"name" : "new post",
}
}


So after the reload, "description" field should be set to null for that record. But the old data ie., "some description" still persists in that field.


How can I force ember data to reset all fields on reload?


Aucun commentaire:

Enregistrer un commentaire