Serialization Ember data 1.0应用程序-en适配器串行化器不工作?
我的问题与此一致: 问题是我无法为每个类型初始化RESTSerializer,因为我需要设置ActiveModelSerializer:Serialization Ember data 1.0应用程序-en适配器串行化器不工作?,serialization,ember.js,adapter,Serialization,Ember.js,Adapter,我的问题与此一致: 问题是我无法为每个类型初始化RESTSerializer,因为我需要设置ActiveModelSerializer: App.FooSerializer = DS.ActiveModelSerializer.extend({attrs: {}}); 将关系设置为嵌入 因此,我想为所有型号设置1个序列化程序。我尝试设置ApplicationSerializer,但在从服务器获得响应时,这并没有调用任何挂钩(我确信我的服务器给出了正确的响应): 设置适配器似乎不起作用: va
App.FooSerializer = DS.ActiveModelSerializer.extend({attrs: {}});
将关系设置为嵌入
因此,我想为所有型号设置1个序列化程序。我尝试设置ApplicationSerializer
,但在从服务器获得响应时,这并没有调用任何挂钩(我确信我的服务器给出了正确的响应):
设置适配器似乎不起作用:
var adapter = require('init/adapter');
App.ApplicationAdapter = adapter.extend({
defaultSerializer: myAdapter //I QUESS THIS IS WRONG?
});
我犯了语法错误吗?还有其他建议吗
编辑:
好的,我发现了我的错误,但不是一个很好的解决办法。似乎我的FooSerializer覆盖了常规的ApplicationSerializer
有什么方法可以同时设置这两个选项吗/ 你不能同时使用这两种方法,但是你可以让你的
FooSerializer
扩展你的ApplicationSerializer
,然后覆盖你想以不同方式使用的方法
App.FooSerializer = App.ApplicationSerializer.extend({
extractArray: function(store, type, payload, id, requestType) {
// alert each record to annoy the user
return this._super(store, type, payload, id, requestType);
},
});
App.FooSerializer = App.ApplicationSerializer.extend({
extractArray: function(store, type, payload, id, requestType) {
// alert each record to annoy the user
return this._super(store, type, payload, id, requestType);
},
});