您好,我是 ember 的新手并正在探索它,我已经能够对资源进行简单的发布,但它会像这样呈现我的对象
{"person":{"atribute1":"jjj","atribute2":"jjj"}}
有没有办法像自定义序列化程序一样删除“登录”,我的端点通过以以下形式传递对象来工作
{"atribute1":"jjj","atribute2":"jjj"}
谢谢。
您好,我是 ember 的新手并正在探索它,我已经能够对资源进行简单的发布,但它会像这样呈现我的对象
{"person":{"atribute1":"jjj","atribute2":"jjj"}}
有没有办法像自定义序列化程序一样删除“登录”,我的端点通过以以下形式传递对象来工作
{"atribute1":"jjj","atribute2":"jjj"}
谢谢。
我能找到的唯一解决方案是在我拥有之前覆盖 createRecord
data[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 之类的属性或类似的属性。