简体   繁体   中英

ember.js hasMany model relationship save

here is a summary of the current state of my app : 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(); (l. 49). As expected a POST request is send to /bookmarks path but request body is not what I excepted.

{
  "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).

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'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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