简体   繁体   English

ember.js hasMany模型关系保存

[英]ember.js hasMany model relationship save

here is a summary of the current state of my app : https://gist.github.com/Daroth/6948372 这是我的应用程序当前状态的摘要: https : //gist.github.com/Daroth/6948372

The version of each framework : 每个框架的版本:

Ember      : 1.0.0
Ember Data : 1.0.0-beta.3
Handlebars : 1.0.0
jQuery     : 1.9.1

And my actual problem is on bookmark.save(); 我的实际问题是在bookmark.save();上。 (l. 49). (l。49)。 As expected a POST request is send to /bookmarks path but request body is not what I excepted. 不出所料,POST请求被发送到/ bookmarks路径,但是请求主体不是我所例外。

{
  "bookmark": {
    "link": "http://google.com",
    "title": "dsfsdf",
    "description": "qsdq",
    "date": null,
    "tags": [null, null]
  }
}

Is send but as you can see tags attribute is filled with an array of null values (one for each previously added tag). 已发送,但如您所见,tags属性填充了一组空值(每个先前添加的标签一个)。

I've try many things but none of them worked. 我尝试了很多事情,但没有一个起作用。

Try 尝试

bookmark.get('tags').pushObject(tag)

if nothing changes try to find all tags created in model after the loop, 如果没有任何变化,请尝试在循环后查找模型中创建的所有标签,

console.log(store.findAll('tag'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM