你好,我是一个相当新的ember和探索它,我已经能够做一个简单的帖子到资源,但它渲染我的对象像这样
{"person":{"atribute1":"jjj","atribute2":"jjj"}}
有没有办法像自定义序列化程序一样删除“登录”,我的端点通过以
的形式传递对象来工作{"atribute1":"jjj","atribute2":"jjj"}
感谢。
答案 0 :(得分:0)
我能找到的唯一解决方案是在我
之前覆盖createRecorddata[root] = this.serialize(record, { includeId: true });
我删除了root的索引并改为:
App.Store = DS.Store.extend({
revision: 11,
adapter : 'App.CustomAdapter'
});
App.CustomAdapter = DS.RESTAdapter.extend({
createRecord: function(store, type, record) {
var root = this.rootForType(type);
var data = {};
data = this.serialize(record, { includeId: true });
this.ajax(this.buildURL(root), "POST", {
data: data,
context: this,
success: function(json) {
Ember.run(this, function(){
if ( this.rootForType(type) == 'login' ) {
return;
}
this.didCreateRecord(store, type, record, json);
});
},
error: function(xhr) {
//HERE to handle login operation failed
this.didError(store, type, record, xhr);
}
});
}
});
可能需要像withRoot或类似的属性。