0
我使用如何改變
DEBUG: -------------------------------
DEBUG: Ember : 1.12.1
DEBUG: Ember Data : 1.13.4
DEBUG: jQuery : 2.1.4
DEBUG: -------------------------------
我的服務器API回覆與剛剛更新對象的ID,例如,這反應到PUT請求灰燼,數據PUT請求預計服務器響應:
{
data:[123],
meta{total:1},
errors:[]
}
如何更改ember-data配置以允許這樣的對象? AFAIK花括號數據期望整個發送對象的響應。 感謝
分辨率:
import DS from "ember-data";
export default DS.Store.extend({
/**
* @tampered _super
* @param internalModel
* @param dataArg
*/
didSaveRecord: function (internalModel, dataArg) {
var data;
if (dataArg && dataArg.data && dataArg.data.id && dataArg.data.id !== 'undefined' && Ember.typeOf(dataArg.data.id) !== 'undefined') {
data = dataArg.data;
}
if (data) {
// normalize relationship IDs into records
this._backburner.schedule("normalizeRelationships", this, "_setupRelationships", internalModel, internalModel.type, data);
this.updateId(internalModel, data);
}
//We first make sure the primary data has been updated
//TODO try to move notification to the user to the end of the runloop
internalModel.adapterDidCommit(data);
},
});
我用DS.RESTSerializer – Marecky